Append optnone and noinline for -O0 optlevel#502
Merged
Conversation
This appears to be NFC change as new pass manager handles --passes=default<O0> correctly. Still must be useful as a safeguard and possibly for the old pass manager that is still used by backend. ┌─────────────────────┬───────────┬──────────────────────┐ │ │ Without │ With │ │ Contract │ (bytes) │ noinline+optnone │ │ │ │ (bytes) │ ├─────────────────────┼───────────┼──────────────────────┤ │ contract.sol:C │ 1,266 │ 1,266 │ ├─────────────────────┼───────────┼──────────────────────┤ │ Fibonacci:Iterative │ 2,506 │ 2,506 │ ├─────────────────────┼───────────┼──────────────────────┤ │ Fibonacci:Recursive │ 3,794 │ 3,794 │ ├─────────────────────┼───────────┼──────────────────────┤ │ Storage │ 3,671 │ 3,671 │ ├─────────────────────┼───────────┼──────────────────────┤ │ Computation │ 5,776 │ 5,776 │ ├─────────────────────┼───────────┼──────────────────────┤ │ Fibonacci:Binet │ 8,786 │ 8,786 │ ├─────────────────────┼───────────┼──────────────────────┤ │ large_div_rem │ 10,705 │ 10,705 │ ├─────────────────────┼───────────┼──────────────────────┤ │ DivisionArithmetics │ 14,831 │ 14,831 │ ├─────────────────────┼───────────┼──────────────────────┤ │ ERC20 │ 32,288 │ 32,288 │ ├─────────────────────┼───────────┼──────────────────────┤ │ ERC20Tester │ 34,589 │ 34,589 │ └─────────────────────┴───────────┴──────────────────────┘
Contributor
Author
|
still not clear why in @elle-j 's example there were SROA and mem2reg and why CSE optimized 2 identical loads, which is what I don't see for the simple c program https://godbolt.org/z/zajPn5e4M |
elle-j
approved these changes
Apr 9, 2026
Contributor
elle-j
left a comment
There was a problem hiding this comment.
...why CSE optimized 2 identical loads, which is what I don't see for the simple c program
You can see the optimization of the loads here:
https://godbolt.org/z/ax4nhbzMf:
And to see the one DAG node (t5), see:
https://godbolt.org/z/bYba7jczr
Initial selection DAG: %bb.0 'square64:'
SelectionDAG has 10 nodes:
t0: ch,glue = EntryToken
t3: i64 = Constant<0>
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t5: i64,ch = load<(load (s64) from %ir.p, align 32)> t0, t2, undef:i64
t6: i64 = mul t5, t5*** MachineFunction at end of ISel ***
# Machine code for function square64: IsSSA, TracksLiveness
Function Live Ins: $x10 in %0
bb.0 (%ir-block.0):
liveins: $x10
%0:gpr = COPY $x10
%1:gpr = LD %0:gpr, 0 :: (load (s64) from %ir.p, align 32)
%2:gpr = MUL %1:gpr, %1:gpr
$x10 = COPY %2:gpr
PseudoRET implicit $x10mem2reg
I don't believe I saw this applied in one of the earlier examples, that was for some higher opt level.
xermicus
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This appears to be NFC change as new pass manager handles --passes=default correctly. Still must be useful as a safeguard and possibly for the old pass manager that is still used by backend.