Skip to content

Commit f2f2997

Browse files
committed
[Constant] Make Constant::getSplatValue return poison on poison
This is a follow up from llvm#141845. I'm not sure if this actually NFC but it doesn't seem to affect any of the in-tree tests. I went through the users of getSplatValue to see if anything could be cleaned up but nothing immediately stuck out.
1 parent 79ae407 commit f2f2997

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3794,11 +3794,6 @@ static Constant *ConstantFoldScalableVectorCall(
37943794
SplatOps.push_back(Op);
37953795
continue;
37963796
}
3797-
// TODO: Should getSplatValue return a poison scalar for a poison vector?
3798-
if (isa<PoisonValue>(Op)) {
3799-
SplatOps.push_back(PoisonValue::get(Op->getType()->getScalarType()));
3800-
continue;
3801-
}
38023797
Constant *Splat = Op->getSplatValue();
38033798
if (!Splat)
38043799
return nullptr;

llvm/lib/IR/Constants.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,8 @@ void ConstantVector::destroyConstantImpl() {
17111711

17121712
Constant *Constant::getSplatValue(bool AllowPoison) const {
17131713
assert(this->getType()->isVectorTy() && "Only valid for vectors!");
1714+
if (isa<PoisonValue>(this))
1715+
return PoisonValue::get(cast<VectorType>(getType())->getElementType());
17141716
if (isa<ConstantAggregateZero>(this))
17151717
return getNullValue(cast<VectorType>(getType())->getElementType());
17161718
if (auto *CI = dyn_cast<ConstantInt>(this))

0 commit comments

Comments
 (0)