Skip to content

Commit e996f1d

Browse files
committed
[RISCV] Add another isel pattern for slliu.w.
Previously we only matched (and (shl X, C1), 0xffffffff << C1) which matches the InstCombine canonicalization order. But its possible to see (shl (and X, 0xffffffff), C1) if the pattern is introduced in SelectionDAG. For example, through expansion of a GEP.
1 parent 0f8386c commit e996f1d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎llvm/lib/Target/RISCV/RISCVInstrInfoB.td‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,8 @@ def : Pat<(and (add GPR:$rs, simm12:$simm12), (i64 0xFFFFFFFF)),
842842
(ADDIWU GPR:$rs, simm12:$simm12)>;
843843
def : Pat<(SLLIUWPat GPR:$rs1, uimm5:$shamt),
844844
(SLLIUW GPR:$rs1, uimm5:$shamt)>;
845+
def : Pat<(shl (and GPR:$rs1, 0xFFFFFFFF), uimm5:$shamt),
846+
(SLLIUW GPR:$rs1, uimm5:$shamt)>;
845847
def : Pat<(and (add GPR:$rs1, GPR:$rs2), (i64 0xFFFFFFFF)),
846848
(ADDWU GPR:$rs1, GPR:$rs2)>;
847849
def : Pat<(and (sub GPR:$rs1, GPR:$rs2), (i64 0xFFFFFFFF)),

‎llvm/test/CodeGen/RISCV/rv64Zbb.ll‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,17 +1070,15 @@ define i128 @slliuw_2(i32 signext %0, i128* %1) {
10701070
;
10711071
; RV64IB-LABEL: slliuw_2:
10721072
; RV64IB: # %bb.0:
1073-
; RV64IB-NEXT: zext.w a0, a0
1074-
; RV64IB-NEXT: slli a0, a0, 4
1073+
; RV64IB-NEXT: slliu.w a0, a0, 4
10751074
; RV64IB-NEXT: add a1, a1, a0
10761075
; RV64IB-NEXT: ld a0, 0(a1)
10771076
; RV64IB-NEXT: ld a1, 8(a1)
10781077
; RV64IB-NEXT: ret
10791078
;
10801079
; RV64IBB-LABEL: slliuw_2:
10811080
; RV64IBB: # %bb.0:
1082-
; RV64IBB-NEXT: zext.w a0, a0
1083-
; RV64IBB-NEXT: slli a0, a0, 4
1081+
; RV64IBB-NEXT: slliu.w a0, a0, 4
10841082
; RV64IBB-NEXT: add a1, a1, a0
10851083
; RV64IBB-NEXT: ld a0, 0(a1)
10861084
; RV64IBB-NEXT: ld a1, 8(a1)

0 commit comments

Comments
 (0)