-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[InstSimplify] Add constant folding support for ucmp
/scmp
intrinsics
#93730
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 all commits
Commits
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
Poseydon42 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,98 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s | ||
|
||
define i8 @scmp_lt() { | ||
; CHECK-LABEL: define i8 @scmp_lt() { | ||
; CHECK-NEXT: ret i8 -1 | ||
; | ||
%1 = call i8 @llvm.scmp(i32 -7, i32 3) | ||
ret i8 %1 | ||
} | ||
|
||
define i8 @scmp_eq() { | ||
; CHECK-LABEL: define i8 @scmp_eq() { | ||
; CHECK-NEXT: ret i8 0 | ||
; | ||
%1 = call i8 @llvm.scmp(i32 2, i32 2) | ||
ret i8 %1 | ||
} | ||
|
||
define i8 @scmp_gt() { | ||
; CHECK-LABEL: define i8 @scmp_gt() { | ||
; CHECK-NEXT: ret i8 1 | ||
; | ||
%1 = call i8 @llvm.scmp(i32 2, i32 -7) | ||
ret i8 %1 | ||
} | ||
|
||
define i8 @ucmp_lt() { | ||
; CHECK-LABEL: define i8 @ucmp_lt() { | ||
; CHECK-NEXT: ret i8 -1 | ||
; | ||
%1 = call i8 @llvm.ucmp(i32 7, i32 12) | ||
ret i8 %1 | ||
} | ||
|
||
define i2 @ucmp_eq() { | ||
; CHECK-LABEL: define i2 @ucmp_eq() { | ||
; CHECK-NEXT: ret i2 0 | ||
; | ||
%1 = call i2 @llvm.ucmp(i32 12, i32 12) | ||
ret i2 %1 | ||
} | ||
|
||
define i100 @ucmp_gt() { | ||
; CHECK-LABEL: define i100 @ucmp_gt() { | ||
; CHECK-NEXT: ret i100 1 | ||
; | ||
%1 = call i100 @llvm.ucmp(i32 7, i32 3) | ||
ret i100 %1 | ||
} | ||
|
||
define i8 @ucmp_poison() { | ||
; CHECK-LABEL: define i8 @ucmp_poison() { | ||
; CHECK-NEXT: ret i8 poison | ||
; | ||
%1 = call i8 @llvm.ucmp(i32 poison, i32 5) | ||
ret i8 %1 | ||
} | ||
|
||
define i8 @scmp_poison() { | ||
; CHECK-LABEL: define i8 @scmp_poison() { | ||
; CHECK-NEXT: ret i8 poison | ||
; | ||
%1 = call i8 @llvm.scmp(i32 0, i32 poison) | ||
ret i8 %1 | ||
} | ||
|
||
define i8 @scmp_undef() { | ||
; CHECK-LABEL: define i8 @scmp_undef() { | ||
; CHECK-NEXT: ret i8 0 | ||
; | ||
%1 = call i8 @llvm.scmp(i32 undef, i32 -12) | ||
ret i8 %1 | ||
} | ||
Poseydon42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
define i8 @ucmp_undef() { | ||
; CHECK-LABEL: define i8 @ucmp_undef() { | ||
; CHECK-NEXT: ret i8 0 | ||
; | ||
%1 = call i8 @llvm.ucmp(i32 2, i32 undef) | ||
ret i8 %1 | ||
} | ||
|
||
define <4 x i8> @ucmp_lt_splat() { | ||
; CHECK-LABEL: define <4 x i8> @ucmp_lt_splat() { | ||
; CHECK-NEXT: ret <4 x i8> <i8 -1, i8 -1, i8 -1, i8 -1> | ||
; | ||
%1 = call <4 x i8> @llvm.ucmp(<4 x i32> splat(i32 1), <4 x i32> splat(i32 3)) | ||
ret <4 x i8> %1 | ||
} | ||
|
||
define <4 x i8> @scmp_nonsplat() { | ||
; CHECK-LABEL: define <4 x i8> @scmp_nonsplat() { | ||
; CHECK-NEXT: ret <4 x i8> <i8 1, i8 0, i8 1, i8 -1> | ||
; | ||
%1 = call <4 x i8> @llvm.scmp(<4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 -1, i32 1, i32 -2, i32 4>) | ||
ret <4 x i8> %1 | ||
} |
Oops, something went wrong.
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.