Skip to content

Commit 45458b2

Browse files
authored
[RISCV] Fix accidentally swapped operands in some PACKH+PACKW patterns. (#162598)
1 parent 9226668 commit 45458b2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,13 @@ def : Pat<(binop_allwusers<or>
702702
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
703703
def : Pat<(binop_allwusers<or>
704704
(or (zexti16 (XLenVT GPR:$rs1)),
705-
(shl GPR:$op1rs1, (XLenVT 24))),
706-
(shl (zexti8 (XLenVT GPR:$op1rs2)), (XLenVT 16))),
705+
(shl GPR:$op1rs2, (XLenVT 24))),
706+
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
707707
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
708708

709709
def : Pat<(i64 (or (or (zexti16 (XLenVT GPR:$rs1)),
710-
(shl (zexti8 (XLenVT GPR:$op1rs2)), (XLenVT 16))),
711-
(sext_inreg (shl GPR:$op1rs1, (XLenVT 24)), i32))),
710+
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
711+
(sext_inreg (shl GPR:$op1rs2, (XLenVT 24)), i32))),
712712
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
713713

714714
// Match a pattern of 2 halfwords being inserted into bits [63:32], with bits

llvm/test/CodeGen/RISCV/rv64zbkb.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ define void @pack_lo_packh_hi_packh_2(i8 zeroext %0, i8 zeroext %1, i8 zeroext %
441441
; RV64ZBKB-LABEL: pack_lo_packh_hi_packh_2:
442442
; RV64ZBKB: # %bb.0:
443443
; RV64ZBKB-NEXT: packh a0, a0, a1
444-
; RV64ZBKB-NEXT: packh a1, a3, a2
444+
; RV64ZBKB-NEXT: packh a1, a2, a3
445445
; RV64ZBKB-NEXT: packw a0, a0, a1
446446
; RV64ZBKB-NEXT: sw a0, 0(a4)
447447
; RV64ZBKB-NEXT: ret
@@ -477,7 +477,7 @@ define void @pack_lo_packh_hi_packh_3(i8 %0, i8 %1, i8 %2, i8 %3, ptr %p) nounwi
477477
; RV64ZBKB-LABEL: pack_lo_packh_hi_packh_3:
478478
; RV64ZBKB: # %bb.0:
479479
; RV64ZBKB-NEXT: packh a0, a0, a1
480-
; RV64ZBKB-NEXT: packh a1, a3, a2
480+
; RV64ZBKB-NEXT: packh a1, a2, a3
481481
; RV64ZBKB-NEXT: packw a0, a0, a1
482482
; RV64ZBKB-NEXT: sw a0, 0(a4)
483483
; RV64ZBKB-NEXT: ret
@@ -509,7 +509,7 @@ define i32 @pack_lo_packh_hi_packh_4(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2
509509
; RV64ZBKB-LABEL: pack_lo_packh_hi_packh_4:
510510
; RV64ZBKB: # %bb.0:
511511
; RV64ZBKB-NEXT: packh a0, a0, a1
512-
; RV64ZBKB-NEXT: packh a1, a3, a2
512+
; RV64ZBKB-NEXT: packh a1, a2, a3
513513
; RV64ZBKB-NEXT: packw a0, a0, a1
514514
; RV64ZBKB-NEXT: ret
515515
%a = zext i8 %0 to i32

0 commit comments

Comments
 (0)