Index: lib/Target/AMDGPU/SIInstrInfo.cpp =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.cpp +++ lib/Target/AMDGPU/SIInstrInfo.cpp @@ -4451,12 +4451,12 @@ // Update dominators. We know that MBB immediately dominates LoopBB, that // LoopBB immediately dominates RemainderBB, and that RemainderBB immediately // dominates all of the successors transferred to it from MBB that MBB used - // to dominate. + // to immediately dominate. if (MDT) { MDT->addNewBlock(LoopBB, &MBB); MDT->addNewBlock(RemainderBB, LoopBB); for (auto &Succ : RemainderBB->successors()) { - if (MDT->dominates(&MBB, Succ)) { + if (&MBB != Succ && MDT->dominates(&MBB, Succ)) { MDT->changeImmediateDominator(Succ, RemainderBB); } }