[llvm] 605e184 - [VectorUtils] Use poison instead of undef in findScalarElement()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 07:20:50 PDT 2024


Author: Nikita Popov
Date: 2024-06-24T16:20:40+02:00
New Revision: 605e18479c8ee272759f2f52fc5259bfb8af7085

URL: https://github.com/llvm/llvm-project/commit/605e18479c8ee272759f2f52fc5259bfb8af7085
DIFF: https://github.com/llvm/llvm-project/commit/605e18479c8ee272759f2f52fc5259bfb8af7085.diff

LOG: [VectorUtils] Use poison instead of undef in findScalarElement()

Out-of-range extractelement returns poison, and so do poison elements
in the shufflevector mask.

Added: 
    

Modified: 
    llvm/lib/Analysis/VectorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 30728ed587509..6e183bbe5bff1 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -165,11 +165,11 @@ Intrinsic::ID llvm::getVectorIntrinsicIDForCall(const CallInst *CI,
 Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
   assert(V->getType()->isVectorTy() && "Not looking at a vector?");
   VectorType *VTy = cast<VectorType>(V->getType());
-  // For fixed-length vector, return undef for out of range access.
+  // For fixed-length vector, return poison for out of range access.
   if (auto *FVTy = dyn_cast<FixedVectorType>(VTy)) {
     unsigned Width = FVTy->getNumElements();
     if (EltNo >= Width)
-      return UndefValue::get(FVTy->getElementType());
+      return PoisonValue::get(FVTy->getElementType());
   }
 
   if (Constant *C = dyn_cast<Constant>(V))
@@ -202,7 +202,7 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
         cast<FixedVectorType>(SVI->getOperand(0)->getType())->getNumElements();
     int InEl = SVI->getMaskValue(EltNo);
     if (InEl < 0)
-      return UndefValue::get(VTy->getElementType());
+      return PoisonValue::get(VTy->getElementType());
     if (InEl < (int)LHSWidth)
       return findScalarElement(SVI->getOperand(0), InEl);
     return findScalarElement(SVI->getOperand(1), InEl - LHSWidth);


        


More information about the llvm-commits mailing list