Skip to content

Commit 196d5fd

Browse files
committed
[RISCV][GISel] Remove most patterns that look for a zext i32->i64 and another integer instruction.
For the most part integer code should promote G_ZEXT to G_AND now. The exception may be when the G_ZEXT is fed by a bitcast from FP, but we don't have any testing of that now. I had to adjust one test that was looking for G_TRUNC+G_ZEXT instead of G_AND.
1 parent 23e9b49 commit 196d5fd

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

llvm/lib/Target/RISCV/RISCVGISel.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,12 @@ def : Pat<(zext_is_sext GPR:$src), (ADDIW GPR:$src, 0)>;
197197

198198
let Predicates = [IsRV64, NotHasStdExtZba] in {
199199
def : Pat<(zext GPR:$src), (SRLI (i64 (SLLI GPR:$src, 32)), 32)>;
200-
201-
// If we're shifting a 32-bit zero extended value left by 0-31 bits, use 2
202-
// shifts instead of 3. This can occur when unsigned is used to index an array.
203-
def : Pat<(shl (zext GPR:$rs), uimm5:$shamt),
204-
(SRLI (i64 (SLLI GPR:$rs, 32)), (ImmSubFrom32 uimm5:$shamt))>;
205200
}
206201

207202
//===----------------------------------------------------------------------===//
208203
// Zb* RV64 i32 patterns not used by SelectionDAG.
209204
//===----------------------------------------------------------------------===//
210205

211206
let Predicates = [HasStdExtZba, IsRV64] in {
212-
def : Pat<(shl (i64 (zext GPR:$rs1)), uimm5:$shamt),
213-
(SLLI_UW GPR:$rs1, uimm5:$shamt)>;
214-
215-
def : Pat<(i64 (add_like_non_imm12 (zext GPR:$rs1), GPR:$rs2)),
216-
(ADD_UW GPR:$rs1, GPR:$rs2)>;
217207
def : Pat<(zext GPR:$src), (ADD_UW GPR:$src, (XLenVT X0))>;
218208
}

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -203,30 +203,6 @@ body: |
203203
$x10 = COPY %4(s64)
204204
...
205205
---
206-
name: slli_uw_s32
207-
legalized: true
208-
regBankSelected: true
209-
tracksRegLiveness: true
210-
body: |
211-
bb.0.entry:
212-
liveins: $x10
213-
214-
; CHECK-LABEL: name: slli_uw_s32
215-
; CHECK: liveins: $x10
216-
; CHECK-NEXT: {{ $}}
217-
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
218-
; CHECK-NEXT: [[SLLI_UW:%[0-9]+]]:gpr = SLLI_UW [[COPY]], 7
219-
; CHECK-NEXT: $x10 = COPY [[SLLI_UW]]
220-
%0:gprb(s64) = COPY $x10
221-
%1:gprb(s32) = G_TRUNC %0(s64)
222-
223-
%2:gprb(s64) = G_ZEXT %1(s32)
224-
%3:gprb(s64) = G_CONSTANT i64 7
225-
%4:gprb(s64) = G_SHL %2, %3
226-
227-
$x10 = COPY %4(s64)
228-
...
229-
---
230206
name: slli_uw_complex
231207
legalized: true
232208
regBankSelected: true
@@ -267,8 +243,8 @@ body: |
267243
; CHECK-NEXT: $x10 = COPY [[ADD_UW]]
268244
%0:gprb(s64) = COPY $x10
269245
%1:gprb(s64) = COPY $x11
270-
%2:gprb(s32) = G_TRUNC %0
271-
%3:gprb(s64) = G_ZEXT %2
246+
%2:gprb(s64) = G_CONSTANT i64 4294967295
247+
%3:gprb(s64) = G_AND %0, %2
272248
%4:gprb(s64) = G_ADD %3, %1
273249
$x10 = COPY %4(s64)
274250
...

0 commit comments

Comments
 (0)