[PATCH] D111898: [SLP]Fix emission of the shrink shuffles.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 09:50:49 PDT 2021
ABataev created this revision.
ABataev added reviewers: RKSimon, spatel, anton-afanasyev, dtemirbulatov, goncharov.
Herald added a subscriber: hiraditya.
ABataev requested review of this revision.
Herald added a project: LLVM.
Need to follow the order of the reused scalars from the
ReuseShuffleIndices mask rather than rely on the natural order.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111898
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder2.ll
Index: llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder2.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder2.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder2.ll
@@ -23,7 +23,7 @@
; CHECK: sw.bb:
; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[G]] to <2 x i32>*
; CHECK-NEXT: [[TMP3:%.*]] = load <2 x i32>, <2 x i32>* [[TMP2]], align 4
-; CHECK-NEXT: [[SHRINK_SHUFFLE:%.*]] = shufflevector <4 x i32> [[SHUFFLE]], <4 x i32> poison, <2 x i32> <i32 0, i32 2>
+; CHECK-NEXT: [[SHRINK_SHUFFLE:%.*]] = shufflevector <4 x i32> [[SHUFFLE]], <4 x i32> poison, <2 x i32> <i32 2, i32 0>
; CHECK-NEXT: [[TMP4:%.*]] = xor <2 x i32> [[SHRINK_SHUFFLE]], <i32 -1, i32 -1>
; CHECK-NEXT: [[TMP5:%.*]] = add <2 x i32> [[TMP3]], [[TMP4]]
; CHECK-NEXT: br label [[SW_EPILOG]]
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5669,17 +5669,18 @@
// block:
// %phi = phi <2 x > { .., %entry} {%shuffle, %block}
- // %2 = shuffle <2 x > %phi, %poison, <4 x > <0, 0, 1, 1>
+ // %2 = shuffle <2 x > %phi, %poison, <4 x > <1, 1, 0, 0>
// ... (use %2)
- // %shuffle = shuffle <2 x> %2, poison, <2 x> {0, 2}
+ // %shuffle = shuffle <2 x> %2, poison, <2 x> {2, 0}
// br %block
- SmallVector<int> UniqueIdxs;
+ SmallVector<int> UniqueIdxs(VF, UndefMaskElem);
SmallSet<int, 4> UsedIdxs;
int Pos = 0;
int Sz = VL.size();
for (int Idx : E->ReuseShuffleIndices) {
- if (Idx != Sz && UsedIdxs.insert(Idx).second)
- UniqueIdxs.emplace_back(Pos);
+ if (Idx != Sz && Idx != UndefMaskElem &&
+ UsedIdxs.insert(Idx).second)
+ UniqueIdxs[Idx] = Pos;
++Pos;
}
assert(VF >= UsedIdxs.size() && "Expected vectorization factor "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111898.380045.patch
Type: text/x-patch
Size: 2192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211015/e7ff5034/attachment.bin>
More information about the llvm-commits
mailing list