Skip to content

Commit b8291ec

Browse files
jsantillan2017sys_zuul
authored andcommitted
The HoistAssumptions function would previously generate instructions
in-between phi nodes, thus breaking the basic block rule mandating to have *all* phi nodes at the beginning of a block. This led subsequent passes that iterate over instructions to find phi nodes to incorrectly stop as soon as it found a non PHI node instruction, when in fact there might still have been phi nodes afterwards. Change-Id: I5fbb4491bab1437270f87a85b9ee5d595e1f9bab
1 parent 3078d8d commit b8291ec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

IGC/Compiler/CISACodeGen/UniformAssumptions.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,20 @@ namespace IGC {
197197
newAssumption->setOperand(0, src);
198198
if (auto srcInst = dyn_cast<Instruction>(src))
199199
{
200-
newAssumption->insertAfter(srcInst);
200+
if (isa<PHINode>(srcInst))
201+
{
202+
newAssumption->insertBefore(
203+
srcInst->getParent()->getFirstNonPHI());
204+
}
205+
else
206+
{
207+
newAssumption->insertAfter(srcInst);
208+
}
201209
}
202210
else
203211
{
204-
newAssumption->insertBefore(F.getEntryBlock().getFirstNonPHI());
212+
newAssumption->insertBefore(
213+
F.getEntryBlock().getFirstNonPHI());
205214
}
206215
check_further = true;
207216
}

0 commit comments

Comments
 (0)