Skip to content

Commit 514f829

Browse files
committed
[RISCV] Use explicit i32/i64 to remove some PACK patterns from RISCVGenDAGISel.inc. NFC
Simplify patterns by removing unnecessary mentions of XLenVT.
1 parent 6a02c0f commit 514f829

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -634,92 +634,92 @@ def : PatGpr<bswap, REV8_RV64, i64>;
634634

635635
let Predicates = [HasStdExtZbkb] in {
636636
def : Pat<(or (and (shl GPR:$rs2, (XLenVT 8)), 0xFFFF),
637-
(zexti8 (XLenVT GPR:$rs1))),
638-
(PACKH GPR:$rs1, GPR:$rs2)>;
639-
def : Pat<(or (shl (zexti8 (XLenVT GPR:$rs2)), (XLenVT 8)),
640-
(zexti8 (XLenVT GPR:$rs1))),
641-
(PACKH GPR:$rs1, GPR:$rs2)>;
637+
zexti8:$rs1),
638+
(PACKH zexti8:$rs1, GPR:$rs2)>;
639+
def : Pat<(or (shl zexti8:$rs2, (XLenVT 8)),
640+
zexti8:$rs1),
641+
(PACKH zexti8:$rs1, zexti8:$rs2)>;
642642
def : Pat<(and (or (shl GPR:$rs2, (XLenVT 8)),
643-
(zexti8 (XLenVT GPR:$rs1))), 0xFFFF),
644-
(PACKH GPR:$rs1, GPR:$rs2)>;
643+
zexti8:$rs1), 0xFFFF),
644+
(PACKH zexti8:$rs1, GPR:$rs2)>;
645645

646646
def : Pat<(binop_allhusers<or> (shl GPR:$rs2, (XLenVT 8)),
647-
(zexti8 (XLenVT GPR:$rs1))),
648-
(PACKH GPR:$rs1, GPR:$rs2)>;
647+
zexti8:$rs1),
648+
(PACKH zexti8:$rs1, GPR:$rs2)>;
649649
} // Predicates = [HasStdExtZbkb]
650650

651651
let Predicates = [HasStdExtZbkb, IsRV32] in {
652-
def : Pat<(i32 (or (zexti16 (i32 GPR:$rs1)), (shl GPR:$rs2, (i32 16)))),
653-
(PACK GPR:$rs1, GPR:$rs2)>;
652+
def : Pat<(i32 (or zexti16:$rs1, (shl GPR:$rs2, (i32 16)))),
653+
(PACK zexti16:$rs1, GPR:$rs2)>;
654654

655-
def : Pat<(or (shl GPR:$rs2, (XLenVT 24)),
656-
(shl (zexti8 (XLenVT GPR:$rs1)), (XLenVT 16))),
657-
(SLLI (XLenVT (PACKH GPR:$rs1, GPR:$rs2)), (XLenVT 16))>;
655+
def : Pat<(i32 (or (shl GPR:$rs2, (XLenVT 24)),
656+
(shl zexti8:$rs1, (XLenVT 16)))),
657+
(SLLI (XLenVT (PACKH zexti8:$rs1, GPR:$rs2)), (XLenVT 16))>;
658658

659659
// Match a pattern of 2 bytes being inserted into bits [31:16], with bits
660660
// bits [15:0] coming from a zero extended value. We can use pack with packh for
661661
// bits [31:16]. If bits [15:0] can also be a packh, it can be matched
662662
// separately.
663-
def : Pat<(or (or (shl GPR:$op1rs2, (XLenVT 24)),
664-
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
665-
(zexti16 (XLenVT GPR:$rs1))),
666-
(PACK (XLenVT GPR:$rs1),
667-
(XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
663+
def : Pat<(i32 (or (or (shl GPR:$op1rs2, (XLenVT 24)),
664+
(shl zexti8:$op1rs1, (XLenVT 16))),
665+
zexti16:$rs1)),
666+
(PACK zexti16:$rs1,
667+
(XLenVT (PACKH zexti8:$op1rs1, GPR:$op1rs2)))>;
668668
}
669669

670670
let Predicates = [HasStdExtZbkb, IsRV64] in {
671-
def : Pat<(i64 (or (zexti32 (i64 GPR:$rs1)), (shl GPR:$rs2, (i64 32)))),
672-
(PACK GPR:$rs1, GPR:$rs2)>;
671+
def : Pat<(i64 (or zexti32:$rs1, (shl GPR:$rs2, (i64 32)))),
672+
(PACK zexti32:$rs1, GPR:$rs2)>;
673673

674-
def : Pat<(or (shl (zexti8 (XLenVT GPR:$rs2)), (XLenVT 24)),
675-
(shl (zexti8 (XLenVT GPR:$rs1)), (XLenVT 16))),
676-
(SLLI (XLenVT (PACKH GPR:$rs1, GPR:$rs2)), (XLenVT 16))>;
674+
def : Pat<(i64 (or (shl zexti8:$rs2, (XLenVT 24)),
675+
(shl zexti8:$rs1, (XLenVT 16)))),
676+
(SLLI (XLenVT (PACKH zexti8:$rs1, zexti8:$rs2)), (XLenVT 16))>;
677677
def : Pat<(binop_allwusers<or> (shl GPR:$rs2, (XLenVT 24)),
678-
(shl (zexti8 (XLenVT GPR:$rs1)), (XLenVT 16))),
679-
(SLLI (XLenVT (PACKH GPR:$rs1, GPR:$rs2)), (XLenVT 16))>;
678+
(shl zexti8:$rs1, (XLenVT 16))),
679+
(SLLI (XLenVT (PACKH zexti8:$rs1, GPR:$rs2)), (XLenVT 16))>;
680680

681681
def : Pat<(binop_allwusers<or> (shl GPR:$rs2, (i64 16)),
682-
(zexti16 (i64 GPR:$rs1))),
683-
(PACKW GPR:$rs1, GPR:$rs2)>;
682+
zexti16:$rs1),
683+
(PACKW zexti16:$rs1, GPR:$rs2)>;
684684
def : Pat<(i64 (or (sext_inreg (shl GPR:$rs2, (i64 16)), i32),
685-
(zexti16 (i64 GPR:$rs1)))),
686-
(PACKW GPR:$rs1, GPR:$rs2)>;
685+
zexti16:$rs1)),
686+
(PACKW zexti16:$rs1, GPR:$rs2)>;
687687

688688
// Match a pattern of 2 bytes being inserted into bits [31:16], with bits
689689
// bits [15:0] coming from a zero extended value, and bits [63:32] being
690690
// ignored. We can use packw with packh for bits [31:16]. If bits [15:0] can
691691
// also be a packh, it can be matched separately.
692692
def : Pat<(binop_allwusers<or>
693693
(or (shl GPR:$op1rs2, (XLenVT 24)),
694-
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
695-
(zexti16 (XLenVT GPR:$rs1))),
696-
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
694+
(shl zexti8:$op1rs1, (XLenVT 16))),
695+
zexti16:$rs1),
696+
(PACKW zexti16:$rs1, (XLenVT (PACKH zexti8:$op1rs1, GPR:$op1rs2)))>;
697697
// We need to manually reassociate the patterns because of the binop_allwusers.
698698
def : Pat<(binop_allwusers<or>
699-
(or (zexti16 (XLenVT GPR:$rs1)),
700-
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
699+
(or zexti16:$rs1,
700+
(shl zexti8:$op1rs1, (XLenVT 16))),
701701
(shl GPR:$op1rs2, (XLenVT 24))),
702-
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
702+
(PACKW zexti16:$rs1, (XLenVT (PACKH zexti8:$op1rs1, GPR:$op1rs2)))>;
703703
def : Pat<(binop_allwusers<or>
704-
(or (zexti16 (XLenVT GPR:$rs1)),
704+
(or zexti16:$rs1,
705705
(shl GPR:$op1rs2, (XLenVT 24))),
706-
(shl (zexti8 (XLenVT GPR:$op1rs1)), (XLenVT 16))),
707-
(PACKW GPR:$rs1, (XLenVT (PACKH GPR:$op1rs1, GPR:$op1rs2)))>;
706+
(shl zexti8:$op1rs1, (XLenVT 16))),
707+
(PACKW zexti16:$rs1, (XLenVT (PACKH zexti8:$op1rs1, GPR:$op1rs2)))>;
708708

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

714714
// Match a pattern of 2 halfwords being inserted into bits [63:32], with bits
715715
// bits [31:0] coming from a zero extended value. We can use pack with packw for
716716
// bits [63:32]. If bits [63:31] can also be a packw, it can be matched
717717
// separately.
718718
def : Pat<(or (or (shl GPR:$op1rs2, (i64 48)),
719-
(shl (zexti16 (i64 GPR:$op1rs1)), (i64 32))),
720-
(zexti32 (i64 GPR:$rs1))),
721-
(PACK (XLenVT GPR:$rs1),
722-
(XLenVT (PACKW GPR:$op1rs1, GPR:$op1rs2)))>;
719+
(shl zexti16:$op1rs1, (i64 32))),
720+
zexti32:$rs1),
721+
(PACK zexti32:$rs1,
722+
(XLenVT (PACKW zexti16:$op1rs1, GPR:$op1rs2)))>;
723723
} // Predicates = [HasStdExtZbkb, IsRV64]
724724

725725
let Predicates = [HasStdExtZbb, IsRV32] in

0 commit comments

Comments
 (0)