Skip to content

Commit 17571be

Browse files
committed
Define Patterns directly
Do not use helper classes and create the patterns directly Move pattern definitions into a similar spot
1 parent 1adef4d commit 17571be

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -730,19 +730,6 @@ let Predicates = [HasSVE_or_SME] in {
730730
defm ABS_ZPmZ : sve_int_un_pred_arit< 0b110, "abs", AArch64abs_mt>;
731731
defm NEG_ZPmZ : sve_int_un_pred_arit< 0b111, "neg", AArch64neg_mt>;
732732

733-
// mul x (splat -1) -> neg x
734-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv16i8, AArch64mul_m1, nxv16i1, NEG_ZPmZ_B , i32>;
735-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv8i16, AArch64mul_m1, nxv8i1, NEG_ZPmZ_H , i32>;
736-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv4i32, AArch64mul_m1, nxv4i1, NEG_ZPmZ_S , i32>;
737-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv2i64, AArch64mul_m1, nxv2i1, NEG_ZPmZ_D , i64>;
738-
739-
let AddedComplexity = 5 in {
740-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv16i8, AArch64mul_p, nxv16i1, NEG_ZPmZ_B_UNDEF, i32>;
741-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv8i16, AArch64mul_p, nxv8i1, NEG_ZPmZ_H_UNDEF, i32>;
742-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv4i32, AArch64mul_p, nxv4i1, NEG_ZPmZ_S_UNDEF, i32>;
743-
def : SVE_2_Op_Neg_One_Passthru_Pat<nxv2i64, AArch64mul_p, nxv2i1, NEG_ZPmZ_D_UNDEF, i64>;
744-
}
745-
746733
defm CLS_ZPmZ : sve_int_un_pred_arit_bitwise< 0b000, "cls", AArch64cls_mt>;
747734
defm CLZ_ZPmZ : sve_int_un_pred_arit_bitwise< 0b001, "clz", AArch64clz_mt>;
748735
defm CNT_ZPmZ : sve_int_un_pred_arit_bitwise< 0b010, "cnt", AArch64cnt_mt>;
@@ -1026,10 +1013,35 @@ let Predicates = [HasSVE_or_SME] in {
10261013

10271014
defm SPLICE_ZPZ : sve_int_perm_splice<"splice", AArch64splice>;
10281015

1029-
def : SVE_2_Op_Neg_One_Replace_Pat<nxv16i8, AArch64mul_m1, nxv16i1, NEG_ZPmZ_B , DUP_ZI_B, i32>;
1030-
def : SVE_2_Op_Neg_One_Replace_Pat<nxv8i16, AArch64mul_m1, nxv8i1, NEG_ZPmZ_H , DUP_ZI_H, i32>;
1031-
def : SVE_2_Op_Neg_One_Replace_Pat<nxv4i32, AArch64mul_m1, nxv4i1, NEG_ZPmZ_S , DUP_ZI_S, i32>;
1032-
def : SVE_2_Op_Neg_One_Replace_Pat<nxv2i64, AArch64mul_m1, nxv2i1, NEG_ZPmZ_D , DUP_ZI_D, i64>;
1016+
// mul x (splat -1) -> neg x
1017+
def : Pat<(nxv16i8 (AArch64mul_m1 nxv16i1:$Op1, nxv16i8:$Op2, (nxv16i8 (splat_vector (i32 -1))))),
1018+
(NEG_ZPmZ_B $Op2, $Op1, $Op2)>;
1019+
def : Pat<(nxv8i16 (AArch64mul_m1 nxv8i1:$Op1, nxv8i16:$Op2, (nxv8i16 (splat_vector (i32 -1))))),
1020+
(NEG_ZPmZ_H $Op2, $Op1, $Op2)>;
1021+
def : Pat<(nxv4i32 (AArch64mul_m1 nxv4i1:$Op1, nxv4i32:$Op2, (nxv4i32 (splat_vector (i32 -1))))),
1022+
(NEG_ZPmZ_S $Op2, $Op1, $Op2)>;
1023+
def : Pat<(nxv2i64 (AArch64mul_m1 nxv2i1:$Op1, nxv2i64:$Op2, (nxv2i64 (splat_vector (i64 -1))))),
1024+
(NEG_ZPmZ_D $Op2, $Op1, $Op2)>;
1025+
1026+
let AddedComplexity = 5 in {
1027+
def : Pat<(nxv16i8 (AArch64mul_p nxv16i1:$Op1, nxv16i8:$Op2, (nxv16i8 (splat_vector (i32 -1))))),
1028+
(NEG_ZPmZ_B_UNDEF $Op2, $Op1, $Op2)>;
1029+
def : Pat<(nxv8i16 (AArch64mul_p nxv8i1:$Op1, nxv8i16:$Op2, (nxv8i16 (splat_vector (i32 -1))))),
1030+
(NEG_ZPmZ_H_UNDEF $Op2, $Op1, $Op2)>;
1031+
def : Pat<(nxv4i32 (AArch64mul_p nxv4i1:$Op1, nxv4i32:$Op2, (nxv4i32 (splat_vector (i32 -1))))),
1032+
(NEG_ZPmZ_S_UNDEF $Op2, $Op1, $Op2)>;
1033+
def : Pat<(nxv2i64 (AArch64mul_p nxv2i1:$Op1, nxv2i64:$Op2, (nxv2i64 (splat_vector (i64 -1))))),
1034+
(NEG_ZPmZ_D_UNDEF $Op2, $Op1, $Op2)>;
1035+
}
1036+
1037+
def : Pat<(nxv16i8 (AArch64mul_m1 nxv16i1:$Op1, (nxv16i8 (splat_vector (i32 -1))), nxv16i8:$Op2)),
1038+
(NEG_ZPmZ_B (DUP_ZI_B -1, 0) , $Op1, $Op2)>;
1039+
def : Pat<(nxv8i16 (AArch64mul_m1 nxv8i1:$Op1, (nxv8i16 (splat_vector (i32 -1))), nxv8i16:$Op2)),
1040+
(NEG_ZPmZ_H (DUP_ZI_H -1, 0) , $Op1, $Op2)>;
1041+
def : Pat<(nxv4i32 (AArch64mul_m1 nxv4i1:$Op1, (nxv4i32 (splat_vector (i32 -1))), nxv4i32:$Op2)),
1042+
(NEG_ZPmZ_S (DUP_ZI_S -1, 0) , $Op1, $Op2)>;
1043+
def : Pat<(nxv2i64 (AArch64mul_m1 nxv2i1:$Op1, (nxv2i64 (splat_vector (i64 -1))), nxv2i64:$Op2)),
1044+
(NEG_ZPmZ_D (DUP_ZI_D -1, 0) , $Op1, $Op2)>;
10331045
} // End HasSVE_or_SME
10341046

10351047
// COMPACT - word and doubleword

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,16 +723,6 @@ class SVE2p1_Cvt_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out
723723
: Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2)),
724724
(!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1))>;
725725

726-
class SVE_2_Op_Neg_One_Replace_Pat<ValueType vt, SDPatternOperator op, ValueType pt,
727-
Instruction inst, Instruction dup_inst, ValueType immT>
728-
: Pat<(vt (op pt:$Op1, (vt (splat_vector (immT -1))), vt:$Op2)),
729-
(inst (dup_inst -1, 0) , $Op1, $Op2)>;
730-
731-
class SVE_2_Op_Neg_One_Passthru_Pat<ValueType vt, SDPatternOperator op, ValueType pt,
732-
Instruction inst, ValueType immT>
733-
: Pat<(vt (op pt:$Op1, vt:$Op2, (vt (splat_vector (immT -1))))),
734-
(inst $Op2, $Op1, $Op2)>;
735-
736726
//===----------------------------------------------------------------------===//
737727
// SVE pattern match helpers.
738728
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)