@@ -45,11 +45,13 @@ bool EVMPeephole::runOnMachineFunction(MachineFunction &MF) {
45
45
return Changed;
46
46
}
47
47
48
- static bool isNegatadAndJumpedOn (const MachineBasicBlock &MBB,
48
+ static bool isNegatedAndJumpedOn (const MachineBasicBlock &MBB,
49
49
MachineBasicBlock::const_iterator I) {
50
50
if (I == MBB.end () || I->getOpcode () != EVM::ISZERO_S)
51
51
return false ;
52
52
++I;
53
+ while (I != MBB.end () && I->getOpcode () == EVM::OR_S)
54
+ ++I;
53
55
if (I == MBB.end ())
54
56
return false ;
55
57
if (I->getOpcode () == EVM::PseudoJUMPI)
@@ -67,23 +69,23 @@ bool EVMPeephole::optimizeConditionaJumps(MachineBasicBlock &MBB) const {
67
69
while (I != MBB.end ()) {
68
70
// Fold ISZERO ISZERO to nothing, only if it's a predicate to JUMPI.
69
71
if (I->getOpcode () == EVM::ISZERO_S &&
70
- isNegatadAndJumpedOn (MBB, std::next (I))) {
72
+ isNegatedAndJumpedOn (MBB, std::next (I))) {
71
73
std::next (I)->eraseFromParent ();
72
74
I->eraseFromParent ();
73
75
return true ;
74
76
}
75
77
76
78
// Fold EQ ISZERO to SUB, only if it's a predicate to JUMPI.
77
79
if (I->getOpcode () == EVM::EQ_S &&
78
- isNegatadAndJumpedOn (MBB, std::next (I))) {
80
+ isNegatedAndJumpedOn (MBB, std::next (I))) {
79
81
I->setDesc (TII->get (EVM::SUB_S));
80
82
std::next (I)->eraseFromParent ();
81
83
return true ;
82
84
}
83
85
84
86
// Fold SUB ISZERO to EQ, only if it's a predicate to JUMPI.
85
87
if (I->getOpcode () == EVM::SUB_S &&
86
- isNegatadAndJumpedOn (MBB, std::next (I))) {
88
+ isNegatedAndJumpedOn (MBB, std::next (I))) {
87
89
I->setDesc (TII->get (EVM::EQ_S));
88
90
std::next (I)->eraseFromParent ();
89
91
return true ;
0 commit comments