Skip to content

Commit 08078fb

Browse files
authored
[RISCV] Fix copy/paste mistake in Sh3Add_UWPat. (#161923)
This pattern is a copy of the pattern in Sh3AddPat but using sh3add.uw instead of sh3add. This is a mistake and the pattern should be the equivalent of the first pattern from Sh1Add_UWPat and Sh2Add_UWPat. These classes were created to share with Andes in a788a1a, but there was so many test changes in there that we must have overlooked the changes to Zba codegen.
1 parent c410e88 commit 08078fb

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,9 @@ multiclass Sh2Add_UWPat<Instruction sh2add_uw> {
808808
}
809809

810810
multiclass Sh3Add_UWPat<Instruction sh3add_uw> {
811-
def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0xFFFFFFF8),
811+
def : Pat<(i64 (add_like_non_imm12 (and (shl GPR:$rs1, (i64 3)), 0x7FFFFFFFF),
812812
(XLenVT GPR:$rs2))),
813-
(sh3add_uw (XLenVT (SRLIW GPR:$rs1, 3)), GPR:$rs2)>;
813+
(sh3add_uw GPR:$rs1, GPR:$rs2)>;
814814
// Use SRLI to clear the LSBs and SHXADD_UW to mask and shift.
815815
def : Pat<(i64 (add_like_non_imm12 (and GPR:$rs1, 0x7FFFFFFF8),
816816
(XLenVT GPR:$rs2))),

llvm/test/CodeGen/RISCV/rv64zba.ll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,11 @@ define i64 @sh3adduw_2(i64 %0, i64 %1) {
409409
;
410410
; RV64ZBA-LABEL: sh3adduw_2:
411411
; RV64ZBA: # %bb.0:
412-
; RV64ZBA-NEXT: slli a0, a0, 3
413-
; RV64ZBA-NEXT: srli a0, a0, 3
414412
; RV64ZBA-NEXT: sh3add.uw a0, a0, a1
415413
; RV64ZBA-NEXT: ret
416414
;
417415
; RV64XANDESPERF-LABEL: sh3adduw_2:
418416
; RV64XANDESPERF: # %bb.0:
419-
; RV64XANDESPERF-NEXT: slli a0, a0, 3
420-
; RV64XANDESPERF-NEXT: srli a0, a0, 3
421417
; RV64XANDESPERF-NEXT: nds.lea.d.ze a0, a1, a0
422418
; RV64XANDESPERF-NEXT: ret
423419
%3 = shl i64 %0, 3
@@ -436,15 +432,11 @@ define i64 @sh3adduw_3(i64 %0, i64 %1) {
436432
;
437433
; RV64ZBA-LABEL: sh3adduw_3:
438434
; RV64ZBA: # %bb.0:
439-
; RV64ZBA-NEXT: slli a0, a0, 3
440-
; RV64ZBA-NEXT: srli a0, a0, 3
441435
; RV64ZBA-NEXT: sh3add.uw a0, a0, a1
442436
; RV64ZBA-NEXT: ret
443437
;
444438
; RV64XANDESPERF-LABEL: sh3adduw_3:
445439
; RV64XANDESPERF: # %bb.0:
446-
; RV64XANDESPERF-NEXT: slli a0, a0, 3
447-
; RV64XANDESPERF-NEXT: srli a0, a0, 3
448440
; RV64XANDESPERF-NEXT: nds.lea.d.ze a0, a1, a0
449441
; RV64XANDESPERF-NEXT: ret
450442
%3 = shl i64 %0, 3
@@ -2681,7 +2673,7 @@ define i64 @srliw_3_sh3add(ptr %0, i32 signext %1) {
26812673
; RV64ZBA-LABEL: srliw_3_sh3add:
26822674
; RV64ZBA: # %bb.0:
26832675
; RV64ZBA-NEXT: srliw a1, a1, 3
2684-
; RV64ZBA-NEXT: sh3add.uw a0, a1, a0
2676+
; RV64ZBA-NEXT: sh3add a0, a1, a0
26852677
; RV64ZBA-NEXT: ld a0, 0(a0)
26862678
; RV64ZBA-NEXT: ret
26872679
;

0 commit comments

Comments
 (0)