[PATCH] D77434: [llvm][Codegen] Make `getVectorTypeBreakdownMVT` work with scalable types.
Francesco Petrogalli via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 08:39:50 PDT 2020
fpetrogalli updated this revision to Diff 256029.
fpetrogalli marked 2 inline comments as done.
fpetrogalli added a comment.
Thank you for the review @efriedma.
I have updated the patch accordingly.
Francesco
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77434/new/
https://reviews.llvm.org/D77434
Files:
llvm/include/llvm/Support/TypeSize.h
llvm/lib/CodeGen/TargetLoweringBase.cpp
Index: llvm/lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -944,42 +944,45 @@
MVT &RegisterVT,
TargetLoweringBase *TLI) {
// Figure out the right, legal destination reg to copy into.
- unsigned NumElts = VT.getVectorNumElements();
+ ElementCount EC = VT.getVectorElementCount();
MVT EltTy = VT.getVectorElementType();
unsigned NumVectorRegs = 1;
- // FIXME: We don't support non-power-of-2-sized vectors for now. Ideally we
- // could break down into LHS/RHS like LegalizeDAG does.
- if (!isPowerOf2_32(NumElts)) {
- NumVectorRegs = NumElts;
- NumElts = 1;
+ // FIXME: We don't support non-power-of-2-sized vectors for now.
+ // Ideally we could break down into LHS/RHS like LegalizeDAG does.
+ if (!isPowerOf2_32(EC.Min)) {
+ // Split EC to unit size (scalable property is preserved).
+ NumVectorRegs = EC.Min;
+ EC = EC / NumVectorRegs;
}
- // Divide the input until we get to a supported size. This will always
- // end with a scalar if the target doesn't support vectors.
- while (NumElts > 1 && !TLI->isTypeLegal(MVT::getVectorVT(EltTy, NumElts))) {
- NumElts >>= 1;
+ // Divide the input until we get to a supported size. This will
+ // always end up with an EC that represent a scalar or a scalable
+ // scalar.
+ while (EC.Min > 1 && !TLI->isTypeLegal(MVT::getVectorVT(EltTy, EC))) {
+ EC.Min >>= 1;
NumVectorRegs <<= 1;
}
NumIntermediates = NumVectorRegs;
- MVT NewVT = MVT::getVectorVT(EltTy, NumElts);
+ MVT NewVT = MVT::getVectorVT(EltTy, EC);
if (!TLI->isTypeLegal(NewVT))
NewVT = EltTy;
IntermediateVT = NewVT;
- unsigned NewVTSize = NewVT.getSizeInBits();
+ unsigned LaneSizeInBits = NewVT.getScalarSizeInBits().getFixedSize();
// Convert sizes such as i33 to i64.
- if (!isPowerOf2_32(NewVTSize))
- NewVTSize = NextPowerOf2(NewVTSize);
+ if (!isPowerOf2_32(LaneSizeInBits))
+ LaneSizeInBits = NextPowerOf2(LaneSizeInBits);
MVT DestVT = TLI->getRegisterType(NewVT);
RegisterVT = DestVT;
if (EVT(DestVT).bitsLT(NewVT)) // Value is expanded, e.g. i64 -> i16.
- return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits());
+ return NumVectorRegs *
+ (LaneSizeInBits / DestVT.getScalarSizeInBits().getFixedSize());
// Otherwise, promotion or legal types use the same number of registers as
// the vector decimated to the appropriate level.
Index: llvm/include/llvm/Support/TypeSize.h
===================================================================
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -37,6 +37,7 @@
return { Min * RHS, Scalable };
}
ElementCount operator/(unsigned RHS) {
+ assert(Min % RHS == 0 && "Min is not a multiple of RHS.");
return { Min / RHS, Scalable };
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77434.256029.patch
Type: text/x-patch
Size: 3023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200408/9f147ccd/attachment.bin>
More information about the llvm-commits
mailing list