Skip to content

Commit

Permalink
Optimize PUSH (#627)
Browse files Browse the repository at this point in the history
GCC misses the optimization in the original code (uses a temporary storage for `r`). The reworked version fixes this.

GCC 12 regression: 
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109667 
- https://godbolt.org/z/avM74o3r6
  • Loading branch information
chfast authored Apr 28, 2023
1 parent 91978cf commit 100c8f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/evmone/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ inline code_iterator push(StackTop stack, ExecutionState& /*state*/, code_iterat
constexpr auto num_full_words = Len / sizeof(uint64_t);
constexpr auto num_partial_bytes = Len % sizeof(uint64_t);
auto data = pos + 1;
uint256 r;

stack.push(0);
auto& r = stack.top();

// Load top partial word.
if constexpr (num_partial_bytes != 0)
Expand All @@ -827,7 +829,6 @@ inline code_iterator push(StackTop stack, ExecutionState& /*state*/, code_iterat
data += sizeof(uint64_t);
}

stack.push(r);
return pos + (Len + 1);
}

Expand Down

0 comments on commit 100c8f9

Please sign in to comment.