Skip to content

Commit feedb35

Browse files
committed
[RISCV][GISel] Correct RORIW patterns.
We had two rotl patterns and no rotr pattern. The order was such that the incorrect rotl pattern was being used.
1 parent bf1a554 commit feedb35

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/Target/RISCV/RISCVGISel.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def : Pat<(i32 (xor GPR:$rs1, (not GPR:$rs2))), (XNOR GPR:$rs1, GPR:$rs2)>;
274274

275275
def : PatGprGpr<rotl, ROLW, i32, i32>;
276276
def : PatGprGpr<rotr, RORW, i32, i32>;
277-
def : Pat<(i32 (rotl GPR:$rs1, uimm5i32:$imm)),
277+
def : Pat<(i32 (rotr GPR:$rs1, uimm5i32:$imm)),
278278
(RORIW GPR:$rs1, (i64 (as_i64imm $imm)))>;
279279

280280
def : Pat<(i32 (rotl GPR:$rs1, uimm5i32:$rs2)),

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/rotate-rv64.mir

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ body: |
117117
; CHECK: liveins: $x10
118118
; CHECK-NEXT: {{ $}}
119119
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
120-
; CHECK-NEXT: [[RORIW:%[0-9]+]]:gpr = RORIW [[COPY]], 15
120+
; CHECK-NEXT: [[RORIW:%[0-9]+]]:gpr = RORIW [[COPY]], 17
121121
; CHECK-NEXT: $x10 = COPY [[RORIW]]
122122
; CHECK-NEXT: PseudoRET implicit $x10
123123
%0:gprb(s64) = COPY $x10
@@ -165,9 +165,8 @@ body: |
165165
; CHECK: liveins: $x10
166166
; CHECK-NEXT: {{ $}}
167167
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
168-
; CHECK-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 15
169-
; CHECK-NEXT: [[RORW:%[0-9]+]]:gpr = RORW [[COPY]], [[ADDI]]
170-
; CHECK-NEXT: $x10 = COPY [[RORW]]
168+
; CHECK-NEXT: [[RORIW:%[0-9]+]]:gpr = RORIW [[COPY]], 15
169+
; CHECK-NEXT: $x10 = COPY [[RORIW]]
171170
; CHECK-NEXT: PseudoRET implicit $x10
172171
%0:gprb(s64) = COPY $x10
173172
%1:gprb(s32) = G_TRUNC %0(s64)

0 commit comments

Comments
 (0)