Skip to content

Commit 2cf5ef6

Browse files
[AArch64] Generate zeroing forms of certain SVE2.2 instructions (11/11)
1 parent 55f9637 commit 2cf5ef6

File tree

3 files changed

+598
-8
lines changed

3 files changed

+598
-8
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,14 +4322,14 @@ let Predicates = [HasSVE2p2orSME2p2] in {
43224322
defm FNEG_ZPzZ : sve_int_un_pred_arit_bitwise_fp_z<0b101, "fneg", AArch64fneg_mt>;
43234323

43244324
// SVE2p2 integer unary arithmetic, zeroing predicate
4325-
defm SXTB_ZPzZ : sve_int_un_pred_arit_h_z<0b000, "sxtb">;
4326-
defm UXTB_ZPzZ : sve_int_un_pred_arit_h_z<0b001, "uxtb">;
4327-
defm SXTH_ZPzZ : sve_int_un_pred_arit_w_z<0b010, "sxth">;
4328-
defm UXTH_ZPzZ : sve_int_un_pred_arit_w_z<0b011, "uxth">;
4325+
defm SXTB_ZPzZ : sve_int_un_pred_arit_h_z<0b000, "sxtb", AArch64sxt_mt>;
4326+
defm UXTB_ZPzZ : sve_int_un_pred_arit_h_z<0b001, "uxtb", AArch64uxt_mt>;
4327+
defm SXTH_ZPzZ : sve_int_un_pred_arit_w_z<0b010, "sxth", AArch64sxt_mt>;
4328+
defm UXTH_ZPzZ : sve_int_un_pred_arit_w_z<0b011, "uxth", AArch64uxt_mt>;
43294329
defm ABS_ZPzZ : sve_int_un_pred_arit_z< 0b110, "abs", AArch64abs_mt>;
43304330
defm NEG_ZPzZ : sve_int_un_pred_arit_z< 0b111, "neg", AArch64neg_mt>;
4331-
def SXTW_ZPzZ_D : sve_int_un_pred_arit_z<0b11, 0b1000, "sxtw", ZPR64>;
4332-
def UXTW_ZPzZ_D : sve_int_un_pred_arit_z<0b11, 0b1010, "uxtw", ZPR64>;
4331+
defm SXTW_ZPzZ : sve_int_un_pred_arit_d_z<0b100, "sxtw", AArch64sxt_mt>;
4332+
defm UXTW_ZPzZ : sve_int_un_pred_arit_d_z<0b101, "uxtw", AArch64uxt_mt>;
43334333

43344334
// SVE predicate count
43354335
defm FIRSTP_XPP : sve_int_pcount_pred_tmp<0b001, "firstp">;

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ multiclass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, Va
651651
(inst $PassThru, $Pg, $Src)>;
652652
}
653653

654+
class SVE_InReg_Extend_PassthruUndefZero<ValueType vt, SDPatternOperator op, ValueType pt,
655+
ValueType inreg_vt, Instruction inst>
656+
: Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt (SVEDup0Undef)))),
657+
(inst $Pg, $Src)>;
658+
654659
class SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op,
655660
ValueType pt, ValueType it,
656661
ComplexPattern cast, Instruction inst>
@@ -4926,10 +4931,14 @@ multiclass sve_int_un_pred_arit_h<bits<3> opc, string asm,
49264931
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _D_UNDEF)>;
49274932
}
49284933

4929-
multiclass sve_int_un_pred_arit_h_z<bits<3> opc, string asm> {
4934+
multiclass sve_int_un_pred_arit_h_z<bits<3> opc, string asm, SDPatternOperator op> {
49304935
def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b0 }, asm, ZPR16>;
49314936
def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
49324937
def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4938+
4939+
def : SVE_InReg_Extend_PassthruUndefZero<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
4940+
def : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
4941+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
49334942
}
49344943

49354944
multiclass sve_int_un_pred_arit_w<bits<3> opc, string asm,
@@ -4949,9 +4958,12 @@ multiclass sve_int_un_pred_arit_w<bits<3> opc, string asm,
49494958
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _D_UNDEF)>;
49504959
}
49514960

4952-
multiclass sve_int_un_pred_arit_w_z<bits<3> opc, string asm> {
4961+
multiclass sve_int_un_pred_arit_w_z<bits<3> opc, string asm, SDPatternOperator op> {
49534962
def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
49544963
def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4964+
4965+
def : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
4966+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
49554967
}
49564968

49574969
multiclass sve_int_un_pred_arit_d<bits<3> opc, string asm,
@@ -4966,6 +4978,12 @@ multiclass sve_int_un_pred_arit_d<bits<3> opc, string asm,
49664978
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _D_UNDEF)>;
49674979
}
49684980

4981+
multiclass sve_int_un_pred_arit_d_z<bits<3> opc, string asm, SDPatternOperator op> {
4982+
def _D : sve_int_un_pred_arit_z<0b11, {opc, 0b0}, asm, ZPR64>;
4983+
4984+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
4985+
}
4986+
49694987
multiclass sve_int_un_pred_arit_bitwise<bits<3> opc, string asm,
49704988
SDPatternOperator op> {
49714989
def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>,

0 commit comments

Comments
 (0)