Skip to content

Commit cc58705

Browse files
authored
Merge pull request #16591 from argotorg/ssa-remove-unnecessary-logic
SSA: Remove unnecessary shuffling logic
2 parents 1993ed6 + 26d6ef1 commit cc58705

1 file changed

Lines changed: 1 addition & 36 deletions

File tree

libyul/backends/evm/ssa/StackShuffler.h

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -415,42 +415,7 @@ class StackShuffler
415415
// if the stack top isn't where it likes to be right now, try to put it somewhere more sensible
416416
if (!_state.isArgsCompatible(stackTop, stackTop))
417417
{
418-
// if the stack top should go into the tail but isn't there yet and we have enough of it in args
419-
if (
420-
_state.requiredInTail(_stack[stackTop]) &&
421-
_state.countInTail(_stack[stackTop]) == 0 &&
422-
_state.countInArgs(_stack[stackTop]) > _state.targetArgsCount(_stack[stackTop])
423-
)
424-
{
425-
// try swapping it with something in the tail that also fixes the top
426-
for (StackOffset offset: _state.stackTailRange())
427-
if (_stack.isValidSwapTarget(offset) && _state.isArgsCompatible(offset, stackTop))
428-
{
429-
_stack.swap(offset);
430-
return {ShuffleHelperResult::Status::StackModified};
431-
}
432-
// otherwise try swapping it with something that needs to go into args
433-
for (StackOffset offset: _state.stackTailRange())
434-
if (_stack.isValidSwapTarget(offset) && _state.countInArgs(_stack[offset]) < _state.targetArgsCount(_stack[offset]))
435-
{
436-
_stack.swap(offset);
437-
return {ShuffleHelperResult::Status::StackModified};
438-
}
439-
// otherwise try swapping it with something that can be popped
440-
for (StackOffset offset: _state.stackTailRange())
441-
if (_stack.isValidSwapTarget(offset) && _stack.canBeFreelyGenerated(_stack[offset]) && !_stack[offset].isLiteralValueID())
442-
{
443-
_stack.swap(offset);
444-
return {ShuffleHelperResult::Status::StackModified};
445-
}
446-
// otherwise try swapping it with a literal
447-
for (StackOffset offset: _state.stackTailRange())
448-
if (_stack.isValidSwapTarget(offset) && _stack[offset].isLiteralValueID())
449-
{
450-
_stack.swap(offset);
451-
return {ShuffleHelperResult::Status::StackModified};
452-
}
453-
}
418+
yulAssert(!_state.requiredInTail(_stack[stackTop]) || _state.countInTail(_stack[stackTop]) > 0);
454419
// try finding a slot that is compatible with the top and also admits the current top:
455420
// - could be that the top slot is used elsewhere in the args (exclude junk)
456421
// - could be that the top slot is something that is only required in the tail

0 commit comments

Comments
 (0)