-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[InstCombine] Fold smin(-a, x - a) + a to smin(x, 0) #167109
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,3 +83,18 @@ entry: | |
| %res = add nuw nsw i32 %min, %max | ||
| ret i32 %res | ||
| } | ||
|
|
||
|
|
||
| define i32 @sadd_min_neg(i32 %x, i32 %a) { | ||
| ; CHECK-LABEL: @sadd_min_neg( | ||
| ; CHECK-NEXT: entry: | ||
| ; CHECK-NEXT: [[RES:%.*]] = call i32 @llvm.smin.i32(i32 [[A:%.*]], i64 5) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CI failed: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/add-min-max.ll:91:15: error: CHECK-NEXT: expected string not found in input |
||
| ; CHECK-NEXT: ret i32 [[RES]] | ||
| ; | ||
| entry: | ||
| %neg_a = sub nsw i32 0, %a | ||
| %x_minus_a = sub nsw i32 %x, %a | ||
| %smin = call i32 @llvm.smin.i32(i32 %neg_a, i32 %x_minus_a) | ||
| %res = add nsw i32 %smin, %a | ||
| ret i32 %res | ||
| } | ||
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.
I don't know why it works... You are matching an fadd instead of an add.