Skip to content

Commit b1a975a

Browse files
committed
extend to OR
1 parent cc9e4e8 commit b1a975a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Target/EVM/EVMPeephole.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ bool EVMPeephole::runOnMachineFunction(MachineFunction &MF) {
4545
return Changed;
4646
}
4747

48-
static bool isNegatadAndJumpedOn(const MachineBasicBlock &MBB,
48+
static bool isNegatedAndJumpedOn(const MachineBasicBlock &MBB,
4949
MachineBasicBlock::const_iterator I) {
5050
if (I == MBB.end() || I->getOpcode() != EVM::ISZERO_S)
5151
return false;
5252
++I;
53+
while (I != MBB.end() && I->getOpcode() == EVM::OR_S)
54+
++I;
5355
if (I == MBB.end())
5456
return false;
5557
if (I->getOpcode() == EVM::PseudoJUMPI)
@@ -67,23 +69,23 @@ bool EVMPeephole::optimizeConditionaJumps(MachineBasicBlock &MBB) const {
6769
while (I != MBB.end()) {
6870
// Fold ISZERO ISZERO to nothing, only if it's a predicate to JUMPI.
6971
if (I->getOpcode() == EVM::ISZERO_S &&
70-
isNegatadAndJumpedOn(MBB, std::next(I))) {
72+
isNegatedAndJumpedOn(MBB, std::next(I))) {
7173
std::next(I)->eraseFromParent();
7274
I->eraseFromParent();
7375
return true;
7476
}
7577

7678
// Fold EQ ISZERO to SUB, only if it's a predicate to JUMPI.
7779
if (I->getOpcode() == EVM::EQ_S &&
78-
isNegatadAndJumpedOn(MBB, std::next(I))) {
80+
isNegatedAndJumpedOn(MBB, std::next(I))) {
7981
I->setDesc(TII->get(EVM::SUB_S));
8082
std::next(I)->eraseFromParent();
8183
return true;
8284
}
8385

8486
// Fold SUB ISZERO to EQ, only if it's a predicate to JUMPI.
8587
if (I->getOpcode() == EVM::SUB_S &&
86-
isNegatadAndJumpedOn(MBB, std::next(I))) {
88+
isNegatedAndJumpedOn(MBB, std::next(I))) {
8789
I->setDesc(TII->get(EVM::EQ_S));
8890
std::next(I)->eraseFromParent();
8991
return true;

0 commit comments

Comments
 (0)