[PATCH] D129136: [VectorCombine] Avoid creating shuffle for extract-extract pattern on scalable vector.
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 02:48:51 PDT 2022
sdesmalen created this revision.
sdesmalen added reviewers: david-arm, fhahn.
Herald added a subscriber: hiraditya.
Herald added a project: All.
sdesmalen requested review of this revision.
Herald added subscribers: llvm-commits, alextsao1999.
Herald added a project: LLVM.
This addresses https://github.com/llvm/llvm-project/issues/56377
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129136
Files:
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/AArch64/extract-scalable.ll
Index: llvm/test/Transforms/VectorCombine/AArch64/extract-scalable.ll
===================================================================
--- llvm/test/Transforms/VectorCombine/AArch64/extract-scalable.ll
+++ llvm/test/Transforms/VectorCombine/AArch64/extract-scalable.ll
@@ -20,3 +20,18 @@
%r = xor i1 %cmp1, %cmp2
ret i1 %r
}
+
+define i32 @extract_extract(<vscale x 4 x i32> %vec) {
+; CHECK-LABEL: @extract_extract(
+; CHECK-NEXT: [[ELT0:%.*]] = extractelement <vscale x 4 x i32> [[VEC:%.*]], i32 0
+; CHECK-NEXT: [[ELT1:%.*]] = extractelement <vscale x 4 x i32> [[VEC]], i32 1
+; CHECK-NEXT: [[IDX:%.*]] = add i32 [[ELT0]], [[ELT1]]
+; CHECK-NEXT: [[ELTIDX:%.*]] = extractelement <vscale x 4 x i32> [[VEC]], i32 [[IDX]]
+; CHECK-NEXT: ret i32 [[ELTIDX]]
+;
+ %elt0 = extractelement <vscale x 4 x i32> %vec, i32 0
+ %elt1 = extractelement <vscale x 4 x i32> %vec, i32 1
+ %idx = add i32 %elt0, %elt1
+ %eltidx = extractelement <vscale x 4 x i32> %vec, i32 %idx
+ ret i32 %eltidx;
+}
Index: llvm/lib/Transforms/Vectorize/VectorCombine.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -414,6 +414,10 @@
static ExtractElementInst *translateExtract(ExtractElementInst *ExtElt,
unsigned NewIndex,
IRBuilder<> &Builder) {
+ // Shufflevectors can only be created for fixed-width vectors.
+ if (!isa<FixedVectorType>(ExtElt->getOperand(0)->getType()))
+ return nullptr;
+
// If the extract can be constant-folded, this code is unsimplified. Defer
// to other passes to handle that.
Value *X = ExtElt->getVectorOperand();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129136.442241.patch
Type: text/x-patch
Size: 1779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220705/4405080f/attachment.bin>
More information about the llvm-commits
mailing list