-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
[RISCV] Enable expansion mul expansion to shNadd x, (slli x, c) #87105
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 |
---|---|---|
|
@@ -551,8 +551,9 @@ define i64 @add_mul_combine_infinite_loop(i64 %x) { | |
; RV32IMB-NEXT: sh3add a1, a1, a2 | ||
; RV32IMB-NEXT: sh1add a0, a0, a0 | ||
; RV32IMB-NEXT: slli a2, a0, 3 | ||
; RV32IMB-NEXT: addi a0, a2, 2047 | ||
; RV32IMB-NEXT: addi a0, a0, 1 | ||
; RV32IMB-NEXT: li a3, 1 | ||
; RV32IMB-NEXT: slli a3, a3, 11 | ||
; RV32IMB-NEXT: sh3add a0, a0, a3 | ||
; RV32IMB-NEXT: sltu a2, a0, a2 | ||
; RV32IMB-NEXT: add a1, a1, a2 | ||
; RV32IMB-NEXT: ret | ||
|
@@ -561,8 +562,8 @@ define i64 @add_mul_combine_infinite_loop(i64 %x) { | |
; RV64IMB: # %bb.0: | ||
; RV64IMB-NEXT: addi a0, a0, 86 | ||
; RV64IMB-NEXT: sh1add a0, a0, a0 | ||
; RV64IMB-NEXT: li a1, -16 | ||
; RV64IMB-NEXT: sh3add a0, a0, a1 | ||
; RV64IMB-NEXT: slli a0, a0, 3 | ||
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. This seems like a mild regression, but I think only indirectly related to this patch. 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. Why do we end up with this instead of 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. This looks to be the result of transformAddImmMulImm. I agree that looks like a questionable transform. |
||
; RV64IMB-NEXT: addi a0, a0, -16 | ||
; RV64IMB-NEXT: ret | ||
%tmp0 = mul i64 %x, 24 | ||
%tmp1 = add i64 %tmp0, 2048 | ||
|
@@ -879,12 +880,31 @@ define i64 @mulneg3000_sub8990_c(i64 %x) { | |
define i1 @pr53831(i32 %x) { | ||
; RV32IMB-LABEL: pr53831: | ||
; RV32IMB: # %bb.0: | ||
; RV32IMB-NEXT: li a0, 0 | ||
; RV32IMB-NEXT: addi a1, a0, 1 | ||
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. This test is checking for an infinite combine loop, but this result is the missed optimization I mentioned in the review summary. |
||
; RV32IMB-NEXT: sh1add a1, a1, a1 | ||
; RV32IMB-NEXT: slli a1, a1, 3 | ||
; RV32IMB-NEXT: addi a1, a1, 1 | ||
; RV32IMB-NEXT: sh1add a0, a0, a0 | ||
; RV32IMB-NEXT: li a2, 1 | ||
; RV32IMB-NEXT: slli a2, a2, 11 | ||
; RV32IMB-NEXT: sh3add a0, a0, a2 | ||
; RV32IMB-NEXT: xor a0, a0, a1 | ||
; RV32IMB-NEXT: seqz a0, a0 | ||
; RV32IMB-NEXT: ret | ||
; | ||
; RV64IMB-LABEL: pr53831: | ||
; RV64IMB: # %bb.0: | ||
; RV64IMB-NEXT: li a0, 0 | ||
; RV64IMB-NEXT: addi a1, a0, 1 | ||
; RV64IMB-NEXT: sh1add a1, a1, a1 | ||
; RV64IMB-NEXT: slliw a1, a1, 3 | ||
; RV64IMB-NEXT: addi a1, a1, 1 | ||
; RV64IMB-NEXT: sh1add a0, a0, a0 | ||
; RV64IMB-NEXT: li a2, 1 | ||
; RV64IMB-NEXT: slli a2, a2, 11 | ||
; RV64IMB-NEXT: sh3add a0, a0, a2 | ||
; RV64IMB-NEXT: sext.w a0, a0 | ||
; RV64IMB-NEXT: xor a0, a0, a1 | ||
; RV64IMB-NEXT: seqz a0, a0 | ||
; RV64IMB-NEXT: ret | ||
%tmp0 = add i32 %x, 1 | ||
%tmp1 = mul i32 %tmp0, 24 | ||
|
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.
Note that we bypass the early shift here, so this sh3add match is actually an improvement. Note that with zbs, the immediate materialization becomes a single bseti.