Skip to content
Merged
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: 16 additions & 1 deletion lib/evmone/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,22 @@ template <int N>
inline void swap(StackTop stack) noexcept
{
static_assert(N >= 1 && N <= 16);
std::swap(stack.top(), stack[N]);

// The simple std::swap(stack.top(), stack[N]) is not used to workaround
// clang missed optimization: https://github.com/llvm/llvm-project/issues/59116
// TODO(clang): Check if #59116 bug fix has been released.

auto& a = stack[N];
auto& t = stack.top();
auto t0 = t[0];
auto t1 = t[1];
auto t2 = t[2];
auto t3 = t[3];
t = a;
a[0] = t0;
a[1] = t1;
a[2] = t2;
a[3] = t3;
}

template <size_t NumTopics>
Expand Down