Skip to content

Commit f16c84b

Browse files
jgu222igcbot
authored andcommitted
When folding a def to its use, need to make sure that use has that def as its single def.
Otherwise, the use cannot be folded to.
1 parent 0b46d60 commit f16c84b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

visa/Optimizer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4467,12 +4467,16 @@ bool Optimizer::foldPseudoNot(G4_BB* bb, INST_LIST_ITER& iter)
44674467
auto&& use = *uses;
44684468
G4_INST* useInst = use.first;
44694469
Gen4_Operand_Number opndPos = use.second;
4470-
if (!useInst->isLogic() || !G4_INST::isSrcNum(opndPos))
4470+
if (!useInst->isLogic() || !G4_INST::isSrcNum(opndPos) ||
4471+
useInst->getSingleDef(opndPos) == nullptr /* not single def */)
44714472
{
44724473
canFold = false;
44734474
break;
44744475
}
44754476

4477+
// sanity check
4478+
assert(useInst->getSingleDef(opndPos) == notInst);
4479+
44764480
// check the case where flag is partially used
44774481
G4_SrcRegRegion* opnd = useInst->getSrc(G4_INST::getSrcNum(opndPos))->asSrcRegRegion();
44784482
if (dst->compareOperand(opnd) != Rel_eq)

0 commit comments

Comments
 (0)