Skip to content

Commit d4710c8

Browse files
committed
[EVM] Fold Or Jumpi
1 parent a9f80c0 commit d4710c8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

llvm/lib/Target/EVM/EVMLowerJumpUnless.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,16 @@ static void lowerJumpUnless(MachineInstr &MI, const EVMInstrInfo *TII,
8282
/// Returns `true` if any fold was performed.
8383
static bool tryFoldJumpUnless(MachineInstr &MI, const EVMInstrInfo *TII) {
8484
auto I = MachineBasicBlock::iterator(&MI);
85-
auto *PrevMI = I == MI.getParent()->begin() ? nullptr : &*std::prev(I);
86-
bool CanFold = PrevMI && (PrevMI->getOpcode() == EVM::ISZERO_S ||
87-
PrevMI->getOpcode() == EVM::EQ_S ||
88-
PrevMI->getOpcode() == EVM::SUB_S);
85+
if (I == MI.getParent()->begin())
86+
return false;
87+
auto PrevMI = std::prev(I);
88+
while (PrevMI != MI.getParent()->begin() && PrevMI->getOpcode() == EVM::OR_S)
89+
PrevMI = std::prev(PrevMI);
90+
if (PrevMI == MI.getParent()->begin())
91+
return false;
92+
bool CanFold = PrevMI->getOpcode() == EVM::ISZERO_S ||
93+
PrevMI->getOpcode() == EVM::EQ_S ||
94+
PrevMI->getOpcode() == EVM::SUB_S;
8995

9096
if (!CanFold)
9197
return false;

0 commit comments

Comments
 (0)