You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current EF stackification algorithm does not account for commutability. While EVMSingleUseExpression was designed to mitigate this issue, it is insufficient for handling cases like calling conventions. To fully resolve the problem of optimal stack configuration computations, functions such as combineStack and other layout creation logic must compare stacks not for strict equality but for equality up to commutable operations. However, this is complex and out of scope for this ticket.
A simpler approach to address the most obvious cases of suboptimal code generation is to maintain the current stack layout. However, when inserting stack permutations, we should evaluate whether it would be more efficient to shuffle the stack in cases where operands can be swapped.
LLVM IR:
define i256 @addrrr(i256 %rs1, i256 %rs2) nounwind {
%res = add i256 %rs1, %rs2
ret i256 %res
}
ASM:
addrrr: ; @addrrr
; %bb.0:
JUMPDEST
SWAP1 <- This swap is not needed
ADD
SWAP1
JUMP
akiramenai
changed the title
Don't reorder stack operands for a commutable instruction
[EVM] Don't reorder stack operands for a commutable instruction
Oct 25, 2024
The current EF stackification algorithm does not account for commutability. While EVMSingleUseExpression was designed to mitigate this issue, it is insufficient for handling cases like calling conventions. To fully resolve the problem of optimal stack configuration computations, functions such as combineStack and other layout creation logic must compare stacks not for strict equality but for equality up to commutable operations. However, this is complex and out of scope for this ticket.
A simpler approach to address the most obvious cases of suboptimal code generation is to maintain the current stack layout. However, when inserting stack permutations, we should evaluate whether it would be more efficient to shuffle the stack in cases where operands can be swapped.
The text was updated successfully, but these errors were encountered: