@@ -66,11 +66,6 @@ static bool IsAcceptableTarget(Instruction *Inst, BasicBlock *SuccToSinkTo,
6666 DominatorTree &DT, LoopInfo &LI) {
6767 assert (Inst && " Instruction to be sunk is null" );
6868 assert (SuccToSinkTo && " Candidate sink target is null" );
69- // The current location of Inst dominates all uses, thus it must dominate
70- // SuccToSinkTo, which is on the IDom chain between the nearest common
71- // dominator to all uses and the current location.
72- assert (DT.dominates (Inst->getParent (), SuccToSinkTo) &&
73- " SuccToSinkTo must be dominated by current Inst location!" );
7469
7570 // It's never legal to sink an instruction into an EH-pad block.
7671 if (SuccToSinkTo->isEHPad ())
@@ -164,6 +159,12 @@ static bool SinkInstruction(Instruction *Inst,
164159 Inst->getParent ()->printAsOperand (dbgs (), false ); dbgs () << " -> " ;
165160 SuccToSinkTo->printAsOperand (dbgs (), false ); dbgs () << " )\n " );
166161
162+ // The current location of Inst dominates all uses, thus it must dominate
163+ // SuccToSinkTo, which is on the IDom chain between the nearest common
164+ // dominator to all uses and the current location.
165+ assert (DT.dominates (BB, SuccToSinkTo) &&
166+ " SuccToSinkTo must be dominated by current Inst location!" );
167+
167168 // Move the instruction.
168169 Inst->moveBefore (SuccToSinkTo->getFirstInsertionPt ());
169170 return true ;
0 commit comments