mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[RISCV] Add a pattern for (sext_inreg (mul (and X, 0xffffffff), (and Y, 0xffffffff)), i32) to suppress MULW formation
We have a special pattern for (mul (and X, 0xffffffff), (and Y, 0xffffffff)), to optimize the ANDs to shift. But if a sext_inreg coms first, we'll form a MULW and limit the effectiveness of the special match. So this patch adds a larger pattern to suppress the MULW formation by emitting a sext.w and then the same output we use for the (mul (and X, 0xffffffff), (and Y, 0xffffffff)). This should all get CSEd. This is the issue I was trying to fix with D99029, but that affected many more tests.
This commit is contained in:
parent
f2b0645b2f
commit
9c604c891f
@ -104,4 +104,11 @@ let Predicates = [HasStdExtM, IsRV64, NotHasStdExtZba] in {
|
||||
// still be better off shifting both left by 32.
|
||||
def : Pat<(i64 (mul (and GPR:$rs1, 0xffffffff), (and GPR:$rs2, 0xffffffff))),
|
||||
(MULHU (SLLI GPR:$rs1, 32), (SLLI GPR:$rs2, 32))>;
|
||||
// Prevent matching the first part of this pattern to mulw. The mul here has
|
||||
// additionals users or the ANDs would have been removed. The above pattern
|
||||
// will be used for the other users. If we form a mulw we'll keep the ANDs alive
|
||||
// and they'll still become SLLI+SRLI.
|
||||
def : Pat<(sext_inreg (mul (and GPR:$rs1, 0xffffffff),
|
||||
(and GPR:$rs2, 0xffffffff)), i32),
|
||||
(ADDIW (MULHU (SLLI GPR:$rs1, 32), (SLLI GPR:$rs2, 32)), 0)>;
|
||||
} // Predicates = [HasStdExtM, IsRV64, NotHasStdExtZba]
|
||||
|
@ -1045,13 +1045,11 @@ define signext i32 @umulo3.i32(i32 signext %0, i32 signext %1, i32* %2) {
|
||||
; RV64-LABEL: umulo3.i32:
|
||||
; RV64: # %bb.0:
|
||||
; RV64-NEXT: slli a1, a1, 32
|
||||
; RV64-NEXT: srli a3, a1, 32
|
||||
; RV64-NEXT: slli a0, a0, 32
|
||||
; RV64-NEXT: srli a4, a0, 32
|
||||
; RV64-NEXT: mulhu a0, a0, a1
|
||||
; RV64-NEXT: srli a0, a0, 32
|
||||
; RV64-NEXT: snez a1, a0
|
||||
; RV64-NEXT: mulw a0, a4, a3
|
||||
; RV64-NEXT: srli a1, a0, 32
|
||||
; RV64-NEXT: snez a1, a1
|
||||
; RV64-NEXT: sext.w a0, a0
|
||||
; RV64-NEXT: sw a1, 0(a2)
|
||||
; RV64-NEXT: ret
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user