Skip to content

Commit

Permalink
[InstCombineVectorOps] Use poison instead of undef as placeholder [NFC]
Browse files Browse the repository at this point in the history
Undef was being used to populate unused vector lanes.
While at it, switch extractelement to use poison as the OOB value (per LangRef)
  • Loading branch information
nunoplopes committed Jul 20, 2023
1 parent d76d5c7 commit 9324e1b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
->getNumElements();

if (SrcIdx < 0)
return replaceInstUsesWith(EI, UndefValue::get(EI.getType()));
return replaceInstUsesWith(EI, PoisonValue::get(EI.getType()));
if (SrcIdx < (int)LHSWidth)
Src = SVI->getOperand(0);
else {
Expand Down Expand Up @@ -1480,10 +1480,10 @@ static Instruction *foldConstantInsEltIntoShuffle(InsertElementInst &InsElt) {
}
++ValI;
}
// Remaining values are filled with 'undef' values.
// Remaining values are filled with 'poison' values.
for (unsigned I = 0; I < NumElts; ++I) {
if (!Values[I]) {
Values[I] = UndefValue::get(InsElt.getType()->getElementType());
Values[I] = PoisonValue::get(InsElt.getType()->getElementType());
Mask[I] = I;
}
}
Expand Down Expand Up @@ -1704,7 +1704,7 @@ Instruction *InstCombinerImpl::visitInsertElementInst(InsertElementInst &IE) {
if (LR.first != &IE && LR.second != &IE) {
// We now have a shuffle of LHS, RHS, Mask.
if (LR.second == nullptr)
LR.second = UndefValue::get(LR.first->getType());
LR.second = PoisonValue::get(LR.first->getType());
return new ShuffleVectorInst(LR.first, LR.second, Mask);
}
}
Expand Down

0 comments on commit 9324e1b

Please sign in to comment.