-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1ee9014
Make uadd_with_overflow scalarizable
Icohedron e91e4c6
Add a test for an intrinsic that is not marked as isTriviallyScalariz…
Icohedron b2a128b
Make sadd, smul, ssub, umul, and usub trivially scalarizable
Icohedron 0ecf77e
Remove unnecessary include from VectorUtils.cpp
Icohedron 0d6eb29
Replace single quotes with double quotes so the update_test_checks.py…
Icohedron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
Icohedron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0 | ||
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.sadd.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.sadd.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.sadd.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.sadd.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
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: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0 | ||
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.smul.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.smul.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.smul.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.smul.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
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: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0 | ||
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.ssub.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.ssub.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.ssub.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.ssub.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
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: [[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) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
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: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0 | ||
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.umul.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.umul.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.umul.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.umul.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s | ||
|
||
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: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0 | ||
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.usub.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.usub.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.usub.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.usub.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b) | ||
%el = extractvalue { <3 x i32>, <3 x i1> } %r, 0 | ||
ret <3 x i32> %el | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.