-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Scalarizer] Make *_with_overflow
intrinsics scalarizable
#126815
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…able Since uadd_with_overflow is now marked isTriviallyScalarizable, another intrinsic needs to take its place for testing the bug fix introduced in llvm#113625 for issue llvm#113624.
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-llvm-analysis Author: Deric Cheung (Icohedron) ChangesAddresses issue #126809
Full diff: https://github.com/llvm/llvm-project/pull/126815.diff 3 Files Affected:
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index ad80e458ab57d..97b29cfc3c737 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -125,6 +125,7 @@ bool llvm::isTriviallyScalarizable(Intrinsic::ID ID,
// https://github.com/llvm/llvm-project/issues/112408
switch (ID) {
case Intrinsic::frexp:
+ case Intrinsic::uadd_with_overflow:
return true;
}
return false;
diff --git a/llvm/test/Transforms/Scalarizer/sincos.ll b/llvm/test/Transforms/Scalarizer/sincos.ll
new file mode 100644
index 0000000000000..6510cbc33ccb7
--- /dev/null
+++ b/llvm/test/Transforms/Scalarizer/sincos.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s
+
+; Test to make sure that struct return intrinsics that are not `isTriviallyScalarizable` do not get scalarized.
+
+define <4 x float> @test_(<4 x float> %Val) {
+; CHECK-LABEL: define <4 x float> @test_(
+; CHECK-SAME: <4 x float> [[VAL:%.*]]) {
+; CHECK-NEXT: [[R:%.*]] = call { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> [[VAL]])
+; CHECK-NEXT: [[EL:%.*]] = extractvalue { <4 x float>, <4 x float> } [[R]], 0
+; CHECK-NEXT: ret <4 x float> [[EL]]
+;
+ %r = call { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> %Val)
+ %el = extractvalue { <4 x float>, <4 x float> } %r, 0
+ ret <4 x float> %el
+}
+
diff --git a/llvm/test/Transforms/Scalarizer/uadd_overflow.ll b/llvm/test/Transforms/Scalarizer/uadd_overflow.ll
index 39094451523a5..f266e5f08b3f6 100644
--- a/llvm/test/Transforms/Scalarizer/uadd_overflow.ll
+++ b/llvm/test/Transforms/Scalarizer/uadd_overflow.ll
@@ -1,13 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s
-; Test to make sure that struct return intrinsics that are not `isTriviallyScalarizable` do not get scalarized.
-
define <3 x i32> @test_(<3 x i32> %a, <3 x i32> %b) {
; CHECK-LABEL: define <3 x i32> @test_(
; CHECK-SAME: <3 x i32> [[A:%.*]], <3 x i32> [[B:%.*]]) {
-; CHECK-NEXT: [[R:%.*]] = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> [[B]], <3 x i32> [[B]])
-; CHECK-NEXT: [[EL:%.*]] = extractvalue { <3 x i32>, <3 x i1> } [[R]], 0
+; CHECK-NEXT: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0
+; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I0]], i32 [[B_I0]])
+; CHECK-NEXT: [[B_I1:%.*]] = extractelement <3 x i32> [[B]], i64 1
+; CHECK-NEXT: [[R_I1:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I1]], i32 [[B_I1]])
+; CHECK-NEXT: [[B_I2:%.*]] = extractelement <3 x i32> [[B]], i64 2
+; CHECK-NEXT: [[R_I2:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I2]], i32 [[B_I2]])
+; CHECK-NEXT: [[EL_ELEM0:%.*]] = extractvalue { i32, i1 } [[R_I0]], 0
+; CHECK-NEXT: [[EL_ELEM01:%.*]] = extractvalue { i32, i1 } [[R_I1]], 0
+; CHECK-NEXT: [[EL_ELEM02:%.*]] = extractvalue { i32, i1 } [[R_I2]], 0
+; CHECK-NEXT: [[EL_UPTO0:%.*]] = insertelement <3 x i32> poison, i32 [[EL_ELEM0]], i64 0
+; CHECK-NEXT: [[EL_UPTO1:%.*]] = insertelement <3 x i32> [[EL_UPTO0]], i32 [[EL_ELEM01]], i64 1
+; CHECK-NEXT: [[EL:%.*]] = insertelement <3 x i32> [[EL_UPTO1]], i32 [[EL_ELEM02]], i64 2
; CHECK-NEXT: ret <3 x i32> [[EL]]
;
%r = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b)
|
Icohedron
added a commit
to Icohedron/llvm-project
that referenced
this pull request
Feb 11, 2025
This commit depends on changes to be merged from PR llvm#126815
RKSimon
reviewed
Feb 12, 2025
uadd_with_overflow
scalarizable*_with_overflow
intrinsics scalarizable
farzonl
reviewed
Feb 12, 2025
farzonl
approved these changes
Feb 12, 2025
RKSimon
reviewed
Feb 13, 2025
RKSimon
approved these changes
Feb 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor
… script run on Windows
joaosaffran
pushed a commit
to joaosaffran/llvm-project
that referenced
this pull request
Feb 14, 2025
) Addresses issue llvm#126809 - Made `uadd_with_overflow`, `sadd_with_overflow`, `usub_with_overflow`, `ssub_with_overflow`, `umul_with_overflow`, and `smul_with_overflow` trivially scalarizable in `isTriviallyScalarizable()` from `VectorUtils.cpp` - Renamed and updated the test `Scalarizer/uadd_overflow.ll` to `Scalarizer/uadd_with_overflow.ll` to check that `uadd_with_overflow` gets scalarized - Added a test `Scalarizer/sincos.ll` to ensure the bug fix llvm#113625 still works
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
) Addresses issue llvm#126809 - Made `uadd_with_overflow`, `sadd_with_overflow`, `usub_with_overflow`, `ssub_with_overflow`, `umul_with_overflow`, and `smul_with_overflow` trivially scalarizable in `isTriviallyScalarizable()` from `VectorUtils.cpp` - Renamed and updated the test `Scalarizer/uadd_overflow.ll` to `Scalarizer/uadd_with_overflow.ll` to check that `uadd_with_overflow` gets scalarized - Added a test `Scalarizer/sincos.ll` to ensure the bug fix llvm#113625 still works
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses issue #126809
uadd_with_overflow
,sadd_with_overflow
,usub_with_overflow
,ssub_with_overflow
,umul_with_overflow
, andsmul_with_overflow
trivially scalarizable inisTriviallyScalarizable()
fromVectorUtils.cpp
Scalarizer/uadd_overflow.ll
toScalarizer/uadd_with_overflow.ll
to check thatuadd_with_overflow
gets scalarizedScalarizer/sincos.ll
to ensure the bug fix [Scalarizer] Fix to only scalarize if intrinsic was marked as isTriviallyScalarizable #113625 still works