Skip to content

Commit 3562867

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

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
@@ -4325,14 +4325,14 @@ let Predicates = [HasSVE2p2orSME2p2] in {
43254325
defm FNEG_ZPzZ : sve_int_un_pred_arit_bitwise_fp_z<0b101, "fneg", AArch64fneg_mt>;
43264326

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

43374337
// SVE predicate count
43384338
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
@@ -662,6 +662,11 @@ multiclass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, Va
662662
(inst $PassThru, $Pg, $Src)>;
663663
}
664664

665+
class SVE_InReg_Extend_PassthruUndefZero<ValueType vt, SDPatternOperator op, ValueType pt,
666+
ValueType inreg_vt, Instruction inst>
667+
: Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt (SVEDup0Undef)))),
668+
(inst $Pg, $Src)>;
669+
665670
class SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op,
666671
ValueType pt, ValueType it,
667672
ComplexPattern cast, Instruction inst>
@@ -4899,10 +4904,14 @@ multiclass sve_int_un_pred_arit_h<bits<3> opc, string asm,
48994904
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _D_UNDEF)>;
49004905
}
49014906

4902-
multiclass sve_int_un_pred_arit_h_z<bits<3> opc, string asm> {
4907+
multiclass sve_int_un_pred_arit_h_z<bits<3> opc, string asm, SDPatternOperator op> {
49034908
def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b0 }, asm, ZPR16>;
49044909
def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
49054910
def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4911+
4912+
def : SVE_InReg_Extend_PassthruUndefZero<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
4913+
def : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
4914+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
49064915
}
49074916

49084917
multiclass sve_int_un_pred_arit_w<bits<3> opc, string asm,
@@ -4922,9 +4931,12 @@ multiclass sve_int_un_pred_arit_w<bits<3> opc, string asm,
49224931
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _D_UNDEF)>;
49234932
}
49244933

4925-
multiclass sve_int_un_pred_arit_w_z<bits<3> opc, string asm> {
4934+
multiclass sve_int_un_pred_arit_w_z<bits<3> opc, string asm, SDPatternOperator op> {
49264935
def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
49274936
def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4937+
4938+
def : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
4939+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
49284940
}
49294941

49304942
multiclass sve_int_un_pred_arit_d<bits<3> opc, string asm,
@@ -4939,6 +4951,12 @@ multiclass sve_int_un_pred_arit_d<bits<3> opc, string asm,
49394951
defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _D_UNDEF)>;
49404952
}
49414953

4954+
multiclass sve_int_un_pred_arit_d_z<bits<3> opc, string asm, SDPatternOperator op> {
4955+
def _D : sve_int_un_pred_arit_z<0b11, {opc, 0b0}, asm, ZPR64>;
4956+
4957+
def : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
4958+
}
4959+
49424960
multiclass sve_int_un_pred_arit_bitwise<bits<3> opc, string asm,
49434961
SDPatternOperator op> {
49444962
def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>,

0 commit comments

Comments
 (0)