[llvm] [ValueTracking] Support scalable vector splats of ConstantInt in isGuaranteedNotToBeUndefOrPoison. (PR #142894)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 00:10:37 PDT 2025
================
@@ -7579,16 +7579,23 @@ static bool isGuaranteedNotToBeUndefOrPoison(
if (isa<UndefValue>(C))
return !includesUndef(Kind);
- if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) || isa<ConstantFP>(V) ||
+ if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) || isa<ConstantFP>(C) ||
isa<ConstantPointerNull>(C) || isa<Function>(C))
return true;
- if (C->getType()->isVectorTy() && !isa<ConstantExpr>(C)) {
- if (includesUndef(Kind) && C->containsUndefElement())
- return false;
- if (includesPoison(Kind) && C->containsPoisonElement())
- return false;
- return !C->containsConstantExpression();
+ if (C->getType()->isVectorTy()) {
+ if (isa<ConstantExpr>(C)) {
+ // Scalable vectors can use a ConstantExpr to build a splat.
+ if (Constant *SplatC = C->getSplatValue())
+ if (isa<ConstantInt>(SplatC))
+ return true;
----------------
dtcxzyw wrote:
Any reason not to support fp/ptr splats?
```suggestion
return isGuaranteedNotToBeUndefOrPoison(SplatC, ...);
```
https://github.com/llvm/llvm-project/pull/142894
More information about the llvm-commits
mailing list