[llvm] f71ea4b - [SLP][REVEC] reorderNodeWithReuses should not be called if all users of a TreeEntry are ShuffleVectorInst. (#118260)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 17:04:08 PST 2024
Author: Han-Kuan Chen
Date: 2024-12-03T09:04:04+08:00
New Revision: f71ea4bc1b01fd7e29048db82b3e21fba74e8dab
URL: https://github.com/llvm/llvm-project/commit/f71ea4bc1b01fd7e29048db82b3e21fba74e8dab
DIFF: https://github.com/llvm/llvm-project/commit/f71ea4bc1b01fd7e29048db82b3e21fba74e8dab.diff
LOG: [SLP][REVEC] reorderNodeWithReuses should not be called if all users of a TreeEntry are ShuffleVectorInst. (#118260)
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/revec.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 04755102643364..33657c26356d65 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6073,6 +6073,23 @@ void BoUpSLP::reorderTopToBottom() {
TE->Scalars.size();
}) &&
"All users must be of VF size.");
+ if (SLPReVec) {
+ assert(SLPReVec && "Only supported by REVEC.");
+ // ShuffleVectorInst does not do reorderOperands (and it should not
+ // because ShuffleVectorInst supports only a limited set of
+ // patterns). Only do reorderNodeWithReuses if all of the users are
+ // not ShuffleVectorInst.
+ if (all_of(TE->UserTreeIndices, [&](const EdgeInfo &EI) {
+ return isa<ShuffleVectorInst>(EI.UserTE->getMainOp());
+ }))
+ continue;
+ assert(none_of(TE->UserTreeIndices,
+ [&](const EdgeInfo &EI) {
+ return isa<ShuffleVectorInst>(
+ EI.UserTE->getMainOp());
+ }) &&
+ "Does not know how to reorder.");
+ }
// Update ordering of the operands with the smaller VF than the given
// one.
reorderNodeWithReuses(*TE, Mask);
diff --git a/llvm/test/Transforms/SLPVectorizer/revec.ll b/llvm/test/Transforms/SLPVectorizer/revec.ll
index b160c0174c0a76..ce13f478d38116 100644
--- a/llvm/test/Transforms/SLPVectorizer/revec.ll
+++ b/llvm/test/Transforms/SLPVectorizer/revec.ll
@@ -447,3 +447,37 @@ for.end.loopexit:
store <4 x i32> %4, ptr %out2, align 4
ret void
}
+
+define void @test14(<8 x i1> %0) {
+; CHECK-LABEL: @test14(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i1> @llvm.vector.insert.v16i1.v8i1(<16 x i1> poison, <8 x i1> [[TMP0:%.*]], i64 0)
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <16 x i1> [[TMP1]], <16 x i1> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: [[TMP3:%.*]] = sext <16 x i1> [[TMP2]] to <16 x i16>
+; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <16 x i16> [[TMP3]], <16 x i16> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP3]], <16 x i16> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <16 x i16> [[TMP3]], <16 x i16> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: br label [[FOR_END_LOOPEXIT:%.*]]
+; CHECK: for.end.loopexit:
+; CHECK-NEXT: [[TMP7:%.*]] = phi <16 x i16> [ [[TMP6]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[TMP8:%.*]] = call <4 x i16> @llvm.vector.extract.v4i16.v16i16(<16 x i16> [[TMP7]], i64 12)
+; CHECK-NEXT: [[OR0:%.*]] = or <4 x i16> [[TMP8]], zeroinitializer
+; CHECK-NEXT: ret void
+;
+entry:
+ %sext0 = sext <8 x i1> %0 to <8 x i16>
+ %sext1 = sext <8 x i1> %0 to <8 x i16>
+ %1 = shufflevector <8 x i16> %sext0, <8 x i16> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %2 = shufflevector <8 x i16> %sext0, <8 x i16> zeroinitializer, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %3 = shufflevector <8 x i16> %sext1, <8 x i16> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %4 = shufflevector <8 x i16> %sext1, <8 x i16> zeroinitializer, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ br label %for.end.loopexit
+
+for.end.loopexit:
+ %phi0 = phi <4 x i16> [ %1, %entry ]
+ %phi1 = phi <4 x i16> [ %2, %entry ]
+ %phi2 = phi <4 x i16> [ %3, %entry ]
+ %phi3 = phi <4 x i16> [ %4, %entry ]
+ %or0 = or <4 x i16> %phi1, zeroinitializer
+ ret void
+}
More information about the llvm-commits
mailing list