[llvm] 9324e1b - [InstCombineVectorOps] Use poison instead of undef as placeholder [NFC]

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 00:15:04 PDT 2023


Author: Nuno Lopes
Date: 2023-07-20T08:14:55+01:00
New Revision: 9324e1be07f3cd99a8714df227640c34e0ba5994

URL: https://github.com/llvm/llvm-project/commit/9324e1be07f3cd99a8714df227640c34e0ba5994
DIFF: https://github.com/llvm/llvm-project/commit/9324e1be07f3cd99a8714df227640c34e0ba5994.diff

LOG: [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)

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index ae18e2c3fe5136..4a5ffef2b08ed4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -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 {
@@ -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;
       }
     }
@@ -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);
         }
       }


        


More information about the llvm-commits mailing list