-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[SelectionDAG] Lowering usub.sat(a, 1) to a - (a != 0) #170076
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
701bcdf
2cc21b2
87c6428
0c20d33
ae1bccf
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 |
|---|---|---|
|
|
@@ -185,3 +185,31 @@ define zeroext i4 @func3(i4 zeroext %x, i4 zeroext %y) nounwind { | |
| %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y); | ||
| ret i4 %tmp; | ||
| } | ||
|
|
||
| define signext i32 @sat_dec_i32(i32 signext %x) nounwind { | ||
| ; RV32I-LABEL: sat_dec_i32: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: snez a1, a0 | ||
| ; RV32I-NEXT: sub a0, a0, a1 | ||
| ; RV32I-NEXT: ret | ||
| ; | ||
| ; RV64I-LABEL: sat_dec_i32: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: snez a1, a0 | ||
| ; RV64I-NEXT: subw a0, a0, a1 | ||
| ; RV64I-NEXT: ret | ||
| ; | ||
| ; RV32IZbb-LABEL: sat_dec_i32: | ||
| ; RV32IZbb: # %bb.0: | ||
| ; RV32IZbb-NEXT: snez a1, a0 | ||
| ; RV32IZbb-NEXT: sub a0, a0, a1 | ||
| ; RV32IZbb-NEXT: ret | ||
| ; | ||
| ; RV64IZbb-LABEL: sat_dec_i32: | ||
| ; RV64IZbb: # %bb.0: | ||
| ; RV64IZbb-NEXT: snez a1, a0 | ||
| ; RV64IZbb-NEXT: subw a0, a0, a1 | ||
| ; RV64IZbb-NEXT: ret | ||
| %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 1) | ||
|
Contributor
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. Does this need a negative test with a non-1 value?
Contributor
Author
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. You mean %y is a constant but not 1? |
||
| ret i32 %tmp | ||
| } | ||
|
Contributor
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. Also test vector case
Contributor
Author
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. About the vector case, is this previously mentioned PR enough? |
||
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.
Do we need to freeze LHS?
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.
https://alive2.llvm.org/ce/z/XSP_Sj
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.
That shows that it works with freeze. Looks like it fails if the freeze is removed?