[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.
Huihui Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 12 11:56:27 PDT 2020
huihuiz added inline comments.
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:6542
- unsigned End = getTransitionType()->getVectorNumElements();
+ auto EC = getTransitionType()->getVectorElementCount();
if (UseSplat)
----------------
efriedma wrote:
> Please write out the type ElementCount.
>
> This is unfortunately turning the explicit assertion if the type is scalable into a later verifier failure in the case where it isn't a splat. Please either fix it properly, or change it so the non-splat codepath still asserts.
Good catch! Thanks Eli!
Going with assert for non-splat codepath for scalable vector.
We should implement like:
```
UndefValue *UndefVal = UndefValue::get(getTransitionType());
Type *I32Ty = Type::getInt32Ty(getTransitionType()->getContext());
return ConstantExpr::getInsertElement(UndefVal, Val, ConstantInt::get(I32Ty, ExtractIdx));
```
But current target lowering will reject scalable vector earlier while checking isTypeLegal(EVT VT).
I am adding a test to check this. So we get assert once target lowering is ready. Then I can bring in this implementation and check for its correctness.
```
define void @simpleOneInstructionPromotion(<vscale x 2 x i32>* %addr1, i32* %dest) {
%in1 = load <vscale x 2 x i32>, <vscale x 2 x i32>* %addr1, align 8
%extract = extractelement <vscale x 2 x i32> %in1, i32 1
%out = or i32 %extract, 1
store i32 %out, i32* %dest, align 4
ret void
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74386/new/
https://reviews.llvm.org/D74386
More information about the cfe-commits
mailing list