-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release/19.x: [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. #107098
Conversation
@llvm/pr-subscribers-llvm-transforms Author: None (llvmbot) ChangesBackport f381cd0 Requested by: @DianQK Full diff: https://github.com/llvm/llvm-project/pull/107098.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index cca9eeebaa53f0..2f3d6b27378aee 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15539,6 +15539,11 @@ void BoUpSLP::computeMinimumValueSizes() {
const TreeEntry *UserTE = E.UserTreeIndices.back().UserTE;
if (TE == UserTE || !TE)
return false;
+ if (!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
+ SelectInst>(U) ||
+ !isa<CastInst, BinaryOperator, FreezeInst, PHINode,
+ SelectInst>(UserTE->getMainOp()))
+ return true;
unsigned UserTESz = DL->getTypeSizeInBits(
UserTE->Scalars.front()->getType());
auto It = MinBWs.find(TE);
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll
new file mode 100644
index 00000000000000..7e7d4352e27733
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-100 | FileCheck %s
+
+define void @test(ptr %i) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[I:%.*]]) {
+; CHECK-NEXT: [[BB:.*]]:
+; CHECK-NEXT: br label %[[BB2:.*]]
+; CHECK: [[BB2]]:
+; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x i32> [ [[TMP3:%.*]], %[[BB2]] ], [ zeroinitializer, %[[BB]] ]
+; CHECK-NEXT: store <2 x i32> [[TMP0]], ptr [[I]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> <i32 0, i32 poison>, <2 x i32> <i32 2, i32 1>
+; CHECK-NEXT: [[TMP2:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i1>
+; CHECK-NEXT: [[TMP3]] = select <2 x i1> [[TMP2]], <2 x i32> zeroinitializer, <2 x i32> zeroinitializer
+; CHECK-NEXT: br label %[[BB2]]
+;
+bb:
+ %i1 = getelementptr i8, ptr %i, i64 4
+ br label %bb2
+
+bb2:
+ %i3 = phi i32 [ %i6, %bb2 ], [ 0, %bb ]
+ %i4 = phi i32 [ %i8, %bb2 ], [ 0, %bb ]
+ store i32 %i3, ptr %i
+ store i32 %i4, ptr %i1
+ %i5 = trunc i32 0 to i1
+ %i6 = select i1 %i5, i32 0, i32 0
+ %i7 = trunc i32 %i4 to i1
+ %i8 = select i1 %i7, i32 0, i32 0
+ br label %bb2
+}
|
Hi, since we are wrapping up LLVM 19.1.0 we are very strict with the fixes we pick at this point. Can you please respond to the following questions to help me understand if this has to be included in the final release or not. Is this PR a fix for a regression or a critical issue? What is the risk of accepting this into the release branch? What is the risk of NOT accepting this into the release branch? |
Yes. It fixes a regression in f6e01b9.
This won't introduce a new regression for this.
This regression comes from a real project in rust-lang/rust#129887. |
…questing its size. Only some instructions should be considered as potentially reducing the size of the operands types, not all instructions should be considered. Fixes llvm#107036 (cherry picked from commit f381cd0)
@DianQK (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. |
Backport f381cd0
Requested by: @DianQK