[llvm] a700fb3 - [SLP] Fixes crash in BoUpSLP::isGatherShuffledEntry()
Vasileios Porpodas via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 12:31:22 PST 2023
Author: Vasileios Porpodas
Date: 2023-02-27T12:29:25-08:00
New Revision: a700fb3d9b31dbcfc9d173c396c1ec644ea40c6d
URL: https://github.com/llvm/llvm-project/commit/a700fb3d9b31dbcfc9d173c396c1ec644ea40c6d
DIFF: https://github.com/llvm/llvm-project/commit/a700fb3d9b31dbcfc9d173c396c1ec644ea40c6d.diff
LOG: [SLP] Fixes crash in BoUpSLP::isGatherShuffledEntry()
Crash caused by: 708eb1b96d9a36f9c0182b7d53c492059778fa35
Differential Revision: https://reviews.llvm.org/D144895
Added:
llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 2388969b30ff6..a6dfbe9313562 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8469,7 +8469,7 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, ArrayRef<Value *> VL,
std::iota(Mask.begin(), Mask.end(), 0);
// Clear undef scalars.
for (int I = 0, Sz = VL.size(); I < Sz; ++I)
- if (isa<PoisonValue>(TE->Scalars[I]))
+ if (isa<PoisonValue>(VL[I]))
Mask[I] = UndefMaskElem;
return TargetTransformInfo::SK_PermuteSingleSrc;
}
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll b/llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
new file mode 100644
index 0000000000000..f3c9847f55b14
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
@@ -0,0 +1,50 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-- -mcpu=corei7 | FileCheck %s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define i1 @foo() {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr null, align 4
+; CHECK-NEXT: br i1 false, label [[TMP15:%.*]], label [[TMP2:%.*]]
+; CHECK: 2:
+; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> zeroinitializer, i64 0
+; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x float> poison, float [[TMP1]], i32 0
+; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x float> [[TMP4]], float [[TMP3]], i32 1
+; CHECK-NEXT: [[TMP6:%.*]] = fadd <2 x float> [[TMP5]], zeroinitializer
+; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <2 x float> [[TMP6]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
+; CHECK-NEXT: [[TMP8:%.*]] = insertelement <4 x float> poison, float [[TMP1]], i32 0
+; CHECK-NEXT: [[TMP9:%.*]] = insertelement <4 x float> [[TMP8]], float [[TMP3]], i32 1
+; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x float> [[TMP9]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
+; CHECK-NEXT: [[TMP11:%.*]] = select <4 x i1> zeroinitializer, <4 x float> [[TMP7]], <4 x float> [[TMP10]]
+; CHECK-NEXT: [[TMP12:%.*]] = fsub <4 x float> [[TMP11]], zeroinitializer
+; CHECK-NEXT: [[TMP13:%.*]] = fadd <4 x float> [[TMP11]], zeroinitializer
+; CHECK-NEXT: [[TMP14:%.*]] = shufflevector <4 x float> [[TMP12]], <4 x float> [[TMP13]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
+; CHECK-NEXT: br label [[TMP15]]
+; CHECK: 15:
+; CHECK-NEXT: [[TMP16:%.*]] = phi <4 x float> [ [[TMP14]], [[TMP2]] ], [ zeroinitializer, [[TMP0:%.*]] ]
+; CHECK-NEXT: ret i1 false
+;
+ %1 = load float, ptr null, align 4
+ br i1 false, label %14, label %2
+
+2: ; preds = %0
+ %3 = extractelement <4 x float> zeroinitializer, i64 0
+ %4 = fadd float %1, 0.000000e+00
+ %5 = fadd float %3, 0.000000e+00
+ %6 = select i1 false, float %4, float %1
+ %7 = fsub float %6, 0.000000e+00
+ %8 = select i1 false, float %5, float %3
+ %9 = fsub float %8, 0.000000e+00
+ %10 = select i1 false, float %4, float %1
+ %11 = fadd float 0.000000e+00, %10
+ %12 = select i1 false, float %5, float %3
+ %13 = fadd float 0.000000e+00, %12
+ br label %14
+
+14: ; preds = %2, %0
+ %15 = phi float [ %7, %2 ], [ 0.000000e+00, %0 ]
+ %16 = phi float [ %9, %2 ], [ 0.000000e+00, %0 ]
+ %17 = phi float [ %11, %2 ], [ 0.000000e+00, %0 ]
+ %18 = phi float [ %13, %2 ], [ 0.000000e+00, %0 ]
+ ret i1 false
+}
More information about the llvm-commits
mailing list