Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3794,11 +3794,6 @@ static Constant *ConstantFoldScalableVectorCall(
SplatOps.push_back(Op);
continue;
}
// TODO: Should getSplatValue return a poison scalar for a poison vector?
if (isa<PoisonValue>(Op)) {
SplatOps.push_back(PoisonValue::get(Op->getType()->getScalarType()));
continue;
}
Constant *Splat = Op->getSplatValue();
if (!Splat)
return nullptr;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,10 @@ TargetTransformInfo::getOperandInfo(const Value *V) {
OperandValueKind OpInfo = OK_AnyValue;
OperandValueProperties OpProps = OP_None;

// undef/poison don't materialize constants.
if (isa<UndefValue>(V))
return {OK_AnyValue, OP_None};

if (isa<ConstantInt>(V) || isa<ConstantFP>(V)) {
if (const auto *CI = dyn_cast<ConstantInt>(V)) {
if (CI->getValue().isPowerOf2())
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/IR/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,8 @@ void ConstantVector::destroyConstantImpl() {

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