-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DAGCombiner][RISCV] Don't propagate the exact flag from udiv/sdiv to urem/srem. #145387
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,82 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=riscv64 -mattr=+m | FileCheck %s | ||
|
||
define i32 @signed(i32 %0, ptr %1) { | ||
; CHECK-LABEL: signed: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: sraiw a2, a0, 31 | ||
; CHECK-NEXT: srliw a2, a2, 24 | ||
; CHECK-NEXT: add a2, a0, a2 | ||
; CHECK-NEXT: andi a2, a2, -256 | ||
; CHECK-NEXT: subw a2, a0, a2 | ||
; CHECK-NEXT: sraiw a0, a0, 8 | ||
; CHECK-NEXT: sw a2, 0(a1) | ||
; CHECK-NEXT: ret | ||
%rem = srem i32 %0, 256 | ||
store i32 %rem, ptr %1, align 4 | ||
%div = sdiv exact i32 %0, 256 | ||
ret i32 %div | ||
} | ||
|
||
define i32 @unsigned(i32 %0, ptr %1) { | ||
; CHECK-LABEL: unsigned: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: slli a2, a0, 32 | ||
; CHECK-NEXT: lui a3, 699051 | ||
; CHECK-NEXT: addi a3, a3, -1365 | ||
; CHECK-NEXT: slli a4, a3, 32 | ||
; CHECK-NEXT: mulhu a2, a2, a4 | ||
; CHECK-NEXT: srli a2, a2, 36 | ||
; CHECK-NEXT: slli a4, a2, 5 | ||
; CHECK-NEXT: slli a2, a2, 3 | ||
; CHECK-NEXT: subw a2, a2, a4 | ||
; CHECK-NEXT: srliw a4, a0, 3 | ||
; CHECK-NEXT: add a2, a0, a2 | ||
; CHECK-NEXT: mulw a0, a4, a3 | ||
; CHECK-NEXT: sw a2, 0(a1) | ||
; CHECK-NEXT: ret | ||
%rem = urem i32 %0, 24 | ||
store i32 %rem, ptr %1, align 4 | ||
%div = udiv exact i32 %0, 24 | ||
ret i32 %div | ||
} | ||
|
||
define i32 @signed_div_first(i32 %0, ptr %1) { | ||
; CHECK-LABEL: signed_div_first: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: sraiw a2, a0, 31 | ||
; CHECK-NEXT: srliw a2, a2, 24 | ||
; CHECK-NEXT: add a3, a0, a2 | ||
; CHECK-NEXT: sraiw a2, a3, 8 | ||
; CHECK-NEXT: andi a3, a3, -256 | ||
; CHECK-NEXT: subw a0, a0, a3 | ||
; CHECK-NEXT: sw a0, 0(a1) | ||
; CHECK-NEXT: mv a0, a2 | ||
; CHECK-NEXT: ret | ||
%div = sdiv exact i32 %0, 256 | ||
%rem = srem i32 %0, 256 | ||
store i32 %rem, ptr %1, align 4 | ||
ret i32 %div | ||
} | ||
|
||
define i32 @unsigned_div_first(i32 %0, ptr %1) { | ||
; CHECK-LABEL: unsigned_div_first: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: slli a2, a0, 32 | ||
; CHECK-NEXT: lui a3, 699051 | ||
; CHECK-NEXT: addi a3, a3, -1365 | ||
; CHECK-NEXT: slli a3, a3, 32 | ||
; CHECK-NEXT: mulhu a2, a2, a3 | ||
; CHECK-NEXT: srli a2, a2, 36 | ||
; CHECK-NEXT: slli a3, a2, 5 | ||
; CHECK-NEXT: slli a4, a2, 3 | ||
; CHECK-NEXT: subw a4, a4, a3 | ||
; CHECK-NEXT: add a0, a0, a4 | ||
; CHECK-NEXT: sw a0, 0(a1) | ||
; CHECK-NEXT: mv a0, a2 | ||
; CHECK-NEXT: ret | ||
%div = udiv exact i32 %0, 24 | ||
%rem = urem i32 %0, 24 | ||
store i32 %rem, ptr %1, align 4 | ||
ret i32 %div | ||
} |
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.