Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions libyul/backends/evm/ssa/StackShuffler.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,23 +446,6 @@ class StackShuffler
_stack.swap(offset);
return {ShuffleHelperResult::Status::StackModified};
}

// try swapping top with a tail slot that has what we need at top
for (StackOffset tailOffset: _state.stackTailRange())
if (
_stack.isValidSwapTarget(tailOffset) &&
_state.isArgsCompatible(tailOffset, stackTop) &&
(!_state.requiredInTail(_stack[tailOffset]) || _state.countInTail(_stack[tailOffset]) > 1) &&
// current top can safely go to tail (not needed in args, or we have excess)
(
!_state.requiredInArgs(_stack[stackTop]) ||
_state.countInArgs(_stack[stackTop]) > _state.targetArgsCount(_stack[stackTop])
)
)
{
_stack.swap(tailOffset);
return {ShuffleHelperResult::Status::StackModified};
}
}

// swap up any slot in args that is out of position and has a slot available in args that it can occupy
Expand Down
8 changes: 4 additions & 4 deletions test/libsolidity/semanticTests/externalContracts/base64.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ contract test {
// gas legacy code: 629800
// gas legacyOptimized: 87926
// gas legacyOptimized code: 429800
// gas ssaCFGOptimized: 79931
// gas ssaCFGOptimized code: 332600
// gas ssaCFGOptimized: 79867
// gas ssaCFGOptimized code: 331800
// encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0
// encode_inline_asm(bytes): 0x20, 1, "f" -> 0x20, 4, "Zg=="
// encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8="
Expand All @@ -61,9 +61,9 @@ contract test {
// gas irOptimized: 1406025
// gas legacy: 1554038
// gas legacyOptimized: 1132031
// gas ssaCFGOptimized: 1388025
// gas ssaCFGOptimized: 1386025
// encode_no_asm_large()
// gas irOptimized: 3512081
// gas legacy: 4600082
// gas legacyOptimized: 2813075
// gas ssaCFGOptimized: 3089081
// gas ssaCFGOptimized: 3078081
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ contract DepositContract is IDepositContract, ERC165 {
// gas legacy code: 1438800
// gas legacyOptimized: 848699
// gas legacyOptimized code: 878200
// gas ssaCFGOptimized: 809663
// gas ssaCFGOptimized code: 570000
// gas ssaCFGOptimized: 809711
// gas ssaCFGOptimized code: 570600
Comment on lines -188 to +189
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a small regression, but it is the only one on external contracts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regression by 0.0059% for runtime and by 0.105% for deploy.. i think it's fine..

// supportsInterface(bytes4): 0x0 -> 0
// supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 #
// supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ contract test {
// gas legacy code: 523600
// gas legacyOptimized: 82667
// gas legacyOptimized code: 369200
// gas ssaCFGOptimized: 77956
// gas ssaCFGOptimized code: 313400
// gas ssaCFGOptimized: 77788
// gas ssaCFGOptimized code: 311000
// prb_pi() -> 3141592656369545286
// gas irOptimized: 55036
// gas legacy: 100657
Expand Down
4 changes: 2 additions & 2 deletions test/libsolidity/semanticTests/externalContracts/snark.sol
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ contract Test {
// gas irOptimized: 275229
// gas legacy: 293579
// gas legacyOptimized: 276313
// gas ssaCFGOptimized: 275795
// gas ssaCFGOptimized: 275787
// verifyTx() -> true
// ~ emit Verified(string): 0x20, 0x16, "Successfully verified."
// gas irOptimized: 818076
// gas legacy: 904397
// gas legacyOptimized: 816770
// gas ssaCFGOptimized: 820130
// gas ssaCFGOptimized: 820110
6 changes: 3 additions & 3 deletions test/libsolidity/semanticTests/externalContracts/strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ contract test {
// gas legacy code: 932600
// gas legacyOptimized: 102639
// gas legacyOptimized code: 612400
// gas ssaCFGOptimized: 96160
// gas ssaCFGOptimized code: 532200
// gas ssaCFGOptimized: 95989
// gas ssaCFGOptimized code: 530000
// toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0
// gas irOptimized: 22646
// gas legacy: 23168
Expand All @@ -80,4 +80,4 @@ contract test {
// gas irOptimized: 1976778
// gas legacy: 4234020
// gas legacyOptimized: 2318668
// gas ssaCFGOptimized: 1882355
// gas ssaCFGOptimized: 1841235
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a 2% improvement.

6 changes: 3 additions & 3 deletions test/libyul/ssa/stackLayoutGenerator/nested_for.yul
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@
// Block0_3 [label="\
// IN: [phi0, phi3, JUNK]\l\
// \l\
// [JUNK, phi3, lit2, phi0]\l\
// [phi3, lit2, phi0]\l\
// add\l\
// [JUNK, phi3, v5]\l\
// [phi3, v5]\l\
// \l\
// OUT: [JUNK, phi3, v5]\l\
// OUT: [phi3, v5]\l\
// "];
// Block0_3 -> Block0_3Exit [arrowhead=none];
// Block0_3Exit [label="Jump" shape=oval];
Expand Down
3 changes: 2 additions & 1 deletion test/libyul/ssa/stackShuffler/swap_junk_over_pop.stack
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ targetStackSize: 4
// (initial)| v0 | * v2
// PUSH lit2| v0 | * v2 lit2
// SWAP2| v0 | lit2 v2 *
// SWAP3| * | lit2 v2 v0
// POP| v0 | lit2 v2
// DUP3| v0 | lit2 v2 v0
Comment on lines -11 to +12
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unfortunate, I would like to fix this somehow.

// +------- +---------------------
// (target)| {} | lit2 v2 v0
// Status: Admissible