Skip to content

Commit 9324e1b

Browse files
committed
[InstCombineVectorOps] Use poison instead of undef as placeholder [NFC]
Undef was being used to populate unused vector lanes. While at it, switch extractelement to use poison as the OOB value (per LangRef)
1 parent d76d5c7 commit 9324e1b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
546546
->getNumElements();
547547

548548
if (SrcIdx < 0)
549-
return replaceInstUsesWith(EI, UndefValue::get(EI.getType()));
549+
return replaceInstUsesWith(EI, PoisonValue::get(EI.getType()));
550550
if (SrcIdx < (int)LHSWidth)
551551
Src = SVI->getOperand(0);
552552
else {
@@ -1480,10 +1480,10 @@ static Instruction *foldConstantInsEltIntoShuffle(InsertElementInst &InsElt) {
14801480
}
14811481
++ValI;
14821482
}
1483-
// Remaining values are filled with 'undef' values.
1483+
// Remaining values are filled with 'poison' values.
14841484
for (unsigned I = 0; I < NumElts; ++I) {
14851485
if (!Values[I]) {
1486-
Values[I] = UndefValue::get(InsElt.getType()->getElementType());
1486+
Values[I] = PoisonValue::get(InsElt.getType()->getElementType());
14871487
Mask[I] = I;
14881488
}
14891489
}
@@ -1704,7 +1704,7 @@ Instruction *InstCombinerImpl::visitInsertElementInst(InsertElementInst &IE) {
17041704
if (LR.first != &IE && LR.second != &IE) {
17051705
// We now have a shuffle of LHS, RHS, Mask.
17061706
if (LR.second == nullptr)
1707-
LR.second = UndefValue::get(LR.first->getType());
1707+
LR.second = PoisonValue::get(LR.first->getType());
17081708
return new ShuffleVectorInst(LR.first, LR.second, Mask);
17091709
}
17101710
}

0 commit comments

Comments
 (0)