Scalable vector should not be evaluated element by element.
Add support to handle scalable vector UndefValue.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Similar issue , current upstream crash at void llvm::Value::doRAUW(llvm::Value *, llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.
opt -S -constprop add.ll -o -
add.ll
define <vscale x 8 x i16> @add() { %r = add <vscale x 8 x i16> undef, undef ret <vscale x 8 x i16> %r }
I will also be moving other sve tests under test/Analysis/ConstantFolding/ to vscale.ll
I'd prefer to handle all the issues in ConstantFoldBinaryInstruction as one review, I think.
Hang on a bit.
Let me see if I can find more issues in ConstantFoldBinaryInstruction.
llvm/lib/IR/ConstantFold.cpp | ||
---|---|---|
1019 | nit: maybe move the subexpression C1->getType()->isVectorTy() && C1->getType()->getVectorIsScalable() to a separate IsScalableVector variable, so that this expression is easier to read? |
Apologies for the delay, was on vacation, also got caught up with a work project in the past two weeks.
There is more we can do for scalable vector for ConstantFoldBinaryInstruction.
E.g., Constant fold binary op with constant splats, refer to https://reviews.llvm.org/D71712
<binop> (<vty> splat(<ty> <C1>)), (<vty> splat(<ty> <C2>)) ==> <vty> splat (<ty> <binop> (C1, C2))
Enable this will require changing API of ConstantVector::getSplat() to take in ElementCount for number of elements.
Probably better to do in a separate patch.
For this patch, we might want to focus on not iterating over scalable vectors.
LGTM
llvm/test/Analysis/ConstantFolding/vscale.ll | ||
---|---|---|
2 | You can drop the first line, since you edited the test by hand. |
nit: maybe move the subexpression
to a separate IsScalableVector variable, so that this expression is easier to read?