forked from OSchip/llvm-project
[GISel] Don't fold convergent instruction across CFG
Before merging two instructions together, GISel does some sanity checks that the folding is legal. However that check was missing that the source of the pattern may be convergent. When the destination location is in a different basic block, the folding is invalid. Differential Revision: https://reviews.llvm.org/D128539
This commit is contained in:
parent
6213dba19f
commit
f4145ddf5b
|
@ -59,6 +59,10 @@ bool InstructionSelector::isObviouslySafeToFold(MachineInstr &MI,
|
|||
std::next(MI.getIterator()) == IntoMI.getIterator())
|
||||
return true;
|
||||
|
||||
// Convergent instructions cannot be moved in the CFG.
|
||||
if (MI.isConvergent() && MI.getParent() != IntoMI.getParent())
|
||||
return false;
|
||||
|
||||
return !MI.mayLoadOrStore() && !MI.mayRaiseFPException() &&
|
||||
!MI.hasUnmodeledSideEffects() && MI.implicit_operands().empty();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue