[llvm] e484e1a - [SVE] Fix casts to <FixedVectorType> in truncateToMinimalBitwidths
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 05:46:21 PDT 2021
Author: Kerry McLaughlin
Date: 2021-07-26T13:44:51+01:00
New Revision: e484e1ae03325823c469684d7d1532f2aadbe98d
URL: https://github.com/llvm/llvm-project/commit/e484e1ae03325823c469684d7d1532f2aadbe98d
DIFF: https://github.com/llvm/llvm-project/commit/e484e1ae03325823c469684d7d1532f2aadbe98d.diff
LOG: [SVE] Fix casts to <FixedVectorType> in truncateToMinimalBitwidths
Fixes more casts to `<FixedVectorType>` for the cases where the
instruction is a Insert/ExtractElementInst.
For fixed-width, this part of truncateToMinimalBitWidths is tested by
AArch64/type-shrinkage-insertelt.ll. I attempted to write a test case for this part
of truncateToMinimalBitWidths which uses scalable vectors, but was unable to add
one. The tests in type-shrinkage-insertelt.ll rely on scalarization to create extract
element instructions for instance, which is not possible for scalable vectors.
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D106163
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 197228cf031b..a841be1879a2 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4049,19 +4049,17 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths(VPTransformState &State) {
// Don't do anything with the operands, just extend the result.
continue;
} else if (auto *IE = dyn_cast<InsertElementInst>(I)) {
- auto Elements = cast<FixedVectorType>(IE->getOperand(0)->getType())
- ->getNumElements();
+ auto Elements =
+ cast<VectorType>(IE->getOperand(0)->getType())->getElementCount();
auto *O0 = B.CreateZExtOrTrunc(
- IE->getOperand(0),
- FixedVectorType::get(ScalarTruncatedTy, Elements));
+ IE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
auto *O1 = B.CreateZExtOrTrunc(IE->getOperand(1), ScalarTruncatedTy);
NewI = B.CreateInsertElement(O0, O1, IE->getOperand(2));
} else if (auto *EE = dyn_cast<ExtractElementInst>(I)) {
- auto Elements = cast<FixedVectorType>(EE->getOperand(0)->getType())
- ->getNumElements();
+ auto Elements =
+ cast<VectorType>(EE->getOperand(0)->getType())->getElementCount();
auto *O0 = B.CreateZExtOrTrunc(
- EE->getOperand(0),
- FixedVectorType::get(ScalarTruncatedTy, Elements));
+ EE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
NewI = B.CreateExtractElement(O0, EE->getOperand(2));
} else {
// If we don't know what to do, be conservative and don't do anything.
More information about the llvm-commits
mailing list