Skip to content

Commit 4b73f6a

Browse files
[AArch64] Generate zeroing forms of certain SVE2.2 instructions (6/11) (#116832)
SVE2.2 introduces instructions with predicated forms with zeroing of the inactive lanes. This allows in some cases to save a `movprfx` or a `mov` instruction when emitting code for `_x` or `_z` variants of intrinsics. This patch adds support for emitting the zeroing forms of certain `CLS`, `CLZ`, `CNT`, `CNOT`, and `NOT` instructions.
1 parent d028eaa commit 4b73f6a

File tree

3 files changed

+2059
-6
lines changed

3 files changed

+2059
-6
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,11 +4314,11 @@ let Predicates = [HasSVE2p2_or_SME2p2] in {
43144314
defm FSQRT_ZPZz : sve_fp_z2op_p_zd_hsd<0b01101, "fsqrt">;
43154315

43164316
// SVE2p2 integer unary arithmetic (bitwise), zeroing predicate
4317-
defm CLS_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b000, "cls">;
4318-
defm CLZ_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b001, "clz">;
4319-
defm CNT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b010, "cnt">;
4320-
defm CNOT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b011, "cnot">;
4321-
defm NOT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b110, "not">;
4317+
defm CLS_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b000, "cls", AArch64cls_mt>;
4318+
defm CLZ_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b001, "clz", AArch64clz_mt>;
4319+
defm CNT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b010, "cnt", AArch64cnt_mt>;
4320+
defm CNOT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b011, "cnot", AArch64cnot_mt>;
4321+
defm NOT_ZPzZ : sve_int_un_pred_arit_bitwise_z<0b110, "not", AArch64not_mt>;
43224322

43234323
// floating point
43244324
defm FABS_ZPzZ : sve_int_un_pred_arit_bitwise_fp_z<0b100, "fabs", AArch64fabs_mt>;

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4975,11 +4975,16 @@ multiclass sve_int_un_pred_arit_bitwise<bits<3> opc, string asm,
49754975
defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
49764976
}
49774977

4978-
multiclass sve_int_un_pred_arit_bitwise_z<bits<3> opc, string asm> {
4978+
multiclass sve_int_un_pred_arit_bitwise_z<bits<3> opc, string asm, SDPatternOperator op> {
49794979
def _B : sve_int_un_pred_arit_z<0b00, { opc, 0b1 }, asm, ZPR8>;
49804980
def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b1 }, asm, ZPR16>;
49814981
def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b1 }, asm, ZPR32>;
49824982
def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b1 }, asm, ZPR64>;
4983+
4984+
defm : SVE_1_Op_PassthruUndefZero_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4985+
defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
4986+
defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4987+
defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
49834988
}
49844989

49854990
multiclass sve_int_un_pred_arit_bitwise_fp<bits<3> opc, string asm,

0 commit comments

Comments
 (0)