Index: lib/CodeGen/MachineInstr.cpp =================================================================== --- lib/CodeGen/MachineInstr.cpp +++ lib/CodeGen/MachineInstr.cpp @@ -1002,14 +1002,20 @@ if (isBundle()) { // Both instructions are bundles, compare MIs inside the bundle. MachineBasicBlock::const_instr_iterator I1 = getIterator(); - MachineBasicBlock::const_instr_iterator E1 = getParent()->instr_end(); + MachineBasicBlock::const_instr_iterator E1 = getBundleEnd(I1); MachineBasicBlock::const_instr_iterator I2 = Other.getIterator(); - MachineBasicBlock::const_instr_iterator E2 = Other.getParent()->instr_end(); - while (++I1 != E1 && I1->isInsideBundle()) { + MachineBasicBlock::const_instr_iterator E2 = getBundleEnd(I2); + while (true) { + ++I1; ++I2; - if (I2 == E2 || !I2->isInsideBundle() || !I1->isIdenticalTo(*I2, Check)) + if (I1 == E1 || I2 == E2) + break; + if (!I1->isIdenticalTo(*I2, Check)) return false; } + // If we did not reach the end of both bundles, then they aren't identical. + if (I1 != E1 || I2 != E2) + return false; } // Check operands to make sure they match.