-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[ConstraintElim] Fix poison check before adding intrinsic facts #136291
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
el-ev
merged 4 commits into
main
from
users/el-ev/04-18-_constraintelim_fix_poison_check_before_adding_intrinsic_facts
Apr 30, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f4bf37b
[ConstraintElim] Fix poison check before adding intrinsic facts
el-ev 3e63609
Merge branch 'main' into users/el-ev/04-18-_constraintelim_fix_poison…
el-ev 4a30bfe
update
el-ev 20b12a7
Merge branch 'main' into users/el-ev/04-18-_constraintelim_fix_poison…
el-ev 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
65 changes: 65 additions & 0 deletions
65
llvm/test/Transforms/ConstraintElimination/uadd-usub-sat.ll
el-ev 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,65 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s | ||
|
|
||
| declare i64 @llvm.uadd.sat.i64(i64, i64) | ||
| declare i64 @llvm.usub.sat.i64(i64, i64) | ||
|
|
||
| define i1 @uadd_sat_uge(i64 noundef %a, i64 noundef %b) { | ||
| ; CHECK-LABEL: define i1 @uadd_sat_uge( | ||
| ; CHECK-SAME: i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) { | ||
| ; CHECK-NEXT: [[ADD_SAT:%.*]] = call i64 @llvm.uadd.sat.i64(i64 [[A]], i64 [[B]]) | ||
| ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i64 [[ADD_SAT]], [[A]] | ||
| ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i64 [[ADD_SAT]], [[B]] | ||
| ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[CMP1]], [[CMP2]] | ||
| ; CHECK-NEXT: ret i1 [[CMP]] | ||
| ; | ||
| %add.sat = call i64 @llvm.uadd.sat.i64(i64 %a, i64 %b) | ||
| %cmp1 = icmp uge i64 %add.sat, %a | ||
| %cmp2 = icmp uge i64 %add.sat, %b | ||
| %cmp = and i1 %cmp1, %cmp2 | ||
| ret i1 %cmp | ||
| } | ||
|
|
||
| define i1 @usub_sat_ule_lhs(i64 noundef %a, i64 noundef %b) { | ||
| ; CHECK-LABEL: define i1 @usub_sat_ule_lhs( | ||
| ; CHECK-SAME: i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) { | ||
| ; CHECK-NEXT: [[SUB_SAT:%.*]] = call i64 @llvm.usub.sat.i64(i64 [[A]], i64 [[B]]) | ||
| ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i64 [[SUB_SAT]], [[A]] | ||
| ; CHECK-NEXT: ret i1 [[CMP]] | ||
| ; | ||
| %sub.sat = call i64 @llvm.usub.sat.i64(i64 %a, i64 %b) | ||
| %cmp = icmp ule i64 %sub.sat, %a | ||
| ret i1 %cmp | ||
| } | ||
|
|
||
| ; Negative test | ||
| define i1 @usub_sat_not_ule_rhs(i64 noundef %a, i64 noundef %b) { | ||
| ; CHECK-LABEL: define i1 @usub_sat_not_ule_rhs( | ||
| ; CHECK-SAME: i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) { | ||
| ; CHECK-NEXT: [[SUB_SAT:%.*]] = call i64 @llvm.usub.sat.i64(i64 [[A]], i64 [[B]]) | ||
| ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i64 [[SUB_SAT]], [[B]] | ||
| ; CHECK-NEXT: ret i1 [[CMP]] | ||
| ; | ||
| %sub.sat = call i64 @llvm.usub.sat.i64(i64 %a, i64 %b) | ||
| %cmp = icmp ule i64 %sub.sat, %b | ||
| ret i1 %cmp | ||
| } | ||
|
|
||
| define i1 @pr135603(i64 %conv6, i64 %str.coerce, ptr %conv) { | ||
| ; CHECK-LABEL: define i1 @pr135603( | ||
| ; CHECK-SAME: i64 [[CONV6:%.*]], i64 [[STR_COERCE:%.*]], ptr [[CONV:%.*]]) { | ||
| ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[CONV]], align 4 | ||
| ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A]], -1 | ||
| ; CHECK-NEXT: [[CONV2:%.*]] = zext nneg i32 [[A]] to i64 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = add i64 [[STR_COERCE]], [[CONV6]] | ||
| ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = call i64 @llvm.usub.sat.i64(i64 [[CONV2]], i64 [[ADD]]) | ||
| ; CHECK-NEXT: ret i1 [[CMP]] | ||
| ; | ||
| %a = load i32, ptr %conv, align 4 | ||
| %cmp = icmp sgt i32 %a, -1 | ||
| %conv2 = zext nneg i32 %a to i64 | ||
| %add = add i64 %str.coerce, %conv6 | ||
| %spec.select = call i64 @llvm.usub.sat.i64(i64 %conv2, i64 %add) | ||
| ret i1 %cmp | ||
| } | ||
|
|
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.