[llvm] 81f8abd - [SLP][REVEC] Fix CreateInsertElement does not use the correct result if MinBWs applied. (#104558)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 06:09:51 PDT 2024
Author: Han-Kuan Chen
Date: 2024-08-16T21:09:48+08:00
New Revision: 81f8abdca4e134009ca1acf9e85ddd4890e39822
URL: https://github.com/llvm/llvm-project/commit/81f8abdca4e134009ca1acf9e85ddd4890e39822
DIFF: https://github.com/llvm/llvm-project/commit/81f8abdca4e134009ca1acf9e85ddd4890e39822.diff
LOG: [SLP][REVEC] Fix CreateInsertElement does not use the correct result if MinBWs applied. (#104558)
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 87b4ed599b5bb1..667d0df781aa4c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11977,7 +11977,7 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL, Value *Root, Type *ScalarTy) {
if (auto *VecTy = dyn_cast<FixedVectorType>(Scalar->getType())) {
assert(SLPReVec && "FixedVectorType is not expected.");
Vec = InsElt = Builder.CreateInsertVector(
- Vec->getType(), Vec, V,
+ Vec->getType(), Vec, Scalar,
Builder.getInt64(Pos * VecTy->getNumElements()));
auto *II = dyn_cast<IntrinsicInst>(InsElt);
if (!II || II->getIntrinsicID() != Intrinsic::vector_insert)
diff --git a/llvm/test/Transforms/SLPVectorizer/revec.ll b/llvm/test/Transforms/SLPVectorizer/revec.ll
index 59201da1d9ac1a..ad1a57c7176197 100644
--- a/llvm/test/Transforms/SLPVectorizer/revec.ll
+++ b/llvm/test/Transforms/SLPVectorizer/revec.ll
@@ -336,3 +336,31 @@ entry:
store <4 x i32> %vmovl.i108, ptr %add.ptr35, align 4
ret void
}
+
+define void @test11(<2 x i64> %0, i64 %1, <2 x i64> %2) {
+; CHECK-LABEL: @test11(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> [[TMP0:%.*]], i64 [[TMP1:%.*]], i32 1
+; CHECK-NEXT: [[TMP4:%.*]] = add <2 x i64> <i64 5, i64 0>, [[TMP2:%.*]]
+; CHECK-NEXT: [[TMP5:%.*]] = trunc <2 x i64> [[TMP4]] to <2 x i16>
+; CHECK-NEXT: [[TMP6:%.*]] = call <4 x i16> @llvm.vector.insert.v4i16.v2i16(<4 x i16> poison, <2 x i16> [[TMP5]], i64 0)
+; CHECK-NEXT: [[TMP7:%.*]] = trunc <2 x i64> [[TMP3]] to <2 x i16>
+; CHECK-NEXT: [[TMP8:%.*]] = call <4 x i16> @llvm.vector.insert.v4i16.v2i16(<4 x i16> [[TMP6]], <2 x i16> [[TMP7]], i64 2)
+; CHECK-NEXT: [[TMP9:%.*]] = trunc <4 x i16> [[TMP8]] to <4 x i8>
+; CHECK-NEXT: [[TMP10:%.*]] = call <4 x i8> @llvm.vector.insert.v4i8.v2i8(<4 x i8> poison, <2 x i8> zeroinitializer, i64 0)
+; CHECK-NEXT: [[TMP11:%.*]] = call <4 x i8> @llvm.vector.insert.v4i8.v2i8(<4 x i8> [[TMP10]], <2 x i8> zeroinitializer, i64 2)
+; CHECK-NEXT: [[TMP12:%.*]] = urem <4 x i8> [[TMP9]], [[TMP11]]
+; CHECK-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[TMP12]], [[TMP11]]
+; CHECK-NEXT: ret void
+;
+entry:
+ %3 = insertelement <2 x i64> %0, i64 %1, i32 1
+ %4 = add <2 x i64> <i64 5, i64 0>, %2
+ %5 = trunc <2 x i64> %3 to <2 x i8>
+ %6 = trunc <2 x i64> %4 to <2 x i8>
+ %7 = urem <2 x i8> %5, zeroinitializer
+ %8 = urem <2 x i8> %6, zeroinitializer
+ %9 = icmp ne <2 x i8> %7, zeroinitializer
+ %10 = icmp ne <2 x i8> %8, zeroinitializer
+ ret void
+}
More information about the llvm-commits
mailing list