diff --git a/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp b/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp --- a/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp +++ b/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp @@ -219,8 +219,11 @@ return false; // Scan back to find an identical S_SET_GPR_IDX_ON - for (MachineBasicBlock::iterator I = std::next(First.getIterator()), - E = MI.getIterator(); I != E; ++I) { + for (MachineBasicBlock::instr_iterator I = std::next(First.getIterator()), + E = MI.getIterator(); + I != E; ++I) { + if (I->isBundle()) + continue; switch (I->getOpcode()) { case AMDGPU::S_SET_GPR_IDX_MODE: return false; @@ -249,9 +252,9 @@ } } - MI.eraseFromParent(); + MI.eraseFromBundle(); for (MachineInstr *RI : ToRemove) - RI->eraseFromParent(); + RI->eraseFromBundle(); return true; } @@ -315,7 +318,8 @@ // Scan the block for two S_SET_GPR_IDX_ON instructions to see if a // second is not needed. Do expensive checks in the optimizeSetGPR() // and limit the distance to 20 instructions for compile time purposes. - for (MachineBasicBlock::iterator MBBI = MBB.begin(); MBBI != MBBE; ) { + for (MachineBasicBlock::instr_iterator MBBI = MBB.instr_begin(); + MBBI != MBBE;) { MachineInstr &MI = *MBBI; ++MBBI;