Skip to content

Commit e1afae0

Browse files
committed
[AArch64][SVE] Add some logical operation DestructiveBinaryComm patterns
Add DestructiveBinaryComm* patterns for ORR, EOR, AND and BIC. The above instructions requires that the source and destination registers are equal, so use movprfx should be beneficial to performance. note: BIC (i.e. A & ~B) is not a commutative operation. Reviewed By: paulwalker-arm, david-arm Differential Revision: https://reviews.llvm.org/D124224
1 parent ad12f46 commit e1afae0

File tree

3 files changed

+315
-45
lines changed

3 files changed

+315
-45
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ let Predicates = [HasSVEorStreamingSVE, UseExperimentalZeroingPseudos] in {
348348
} // End HasSVEorStreamingSVE, UseExperimentalZeroingPseudos
349349

350350
let Predicates = [HasSVEorStreamingSVE] in {
351-
defm ORR_ZPmZ : sve_int_bin_pred_log<0b000, "orr", int_aarch64_sve_orr>;
352-
defm EOR_ZPmZ : sve_int_bin_pred_log<0b001, "eor", int_aarch64_sve_eor>;
353-
defm AND_ZPmZ : sve_int_bin_pred_log<0b010, "and", int_aarch64_sve_and>;
354-
defm BIC_ZPmZ : sve_int_bin_pred_log<0b011, "bic", int_aarch64_sve_bic>;
351+
defm ORR_ZPmZ : sve_int_bin_pred_log<0b000, "orr", "ORR_ZPZZ", int_aarch64_sve_orr, DestructiveBinaryComm>;
352+
defm EOR_ZPmZ : sve_int_bin_pred_log<0b001, "eor", "EOR_ZPZZ", int_aarch64_sve_eor, DestructiveBinaryComm>;
353+
defm AND_ZPmZ : sve_int_bin_pred_log<0b010, "and", "AND_ZPZZ", int_aarch64_sve_and, DestructiveBinaryComm>;
354+
defm BIC_ZPmZ : sve_int_bin_pred_log<0b011, "bic", "BIC_ZPZZ", int_aarch64_sve_bic, DestructiveBinary>;
355355

356356
defm ADD_ZI : sve_int_arith_imm0<0b000, "add", add>;
357357
defm SUB_ZI : sve_int_arith_imm0<0b001, "sub", sub>;
@@ -463,6 +463,11 @@ let Predicates = [HasSVEorStreamingSVE] in {
463463
defm FMIN_ZPZI : sve_fp_2op_i_p_zds_hfd<sve_fpimm_zero_one, fpimm0, fpimm_one, AArch64fmin_p>;
464464

465465
let Predicates = [HasSVE, UseExperimentalZeroingPseudos] in {
466+
defm ORR_ZPZZ : sve_int_bin_pred_zeroing_bhsd<int_aarch64_sve_orr>;
467+
defm EOR_ZPZZ : sve_int_bin_pred_zeroing_bhsd<int_aarch64_sve_eor>;
468+
defm AND_ZPZZ : sve_int_bin_pred_zeroing_bhsd<int_aarch64_sve_and>;
469+
defm BIC_ZPZZ : sve_int_bin_pred_zeroing_bhsd<int_aarch64_sve_bic>;
470+
466471
defm FADD_ZPZI : sve_fp_2op_i_p_zds_zeroing_hfd<sve_fpimm_half_one, fpimm_half, fpimm_one, int_aarch64_sve_fadd>;
467472
defm FSUB_ZPZI : sve_fp_2op_i_p_zds_zeroing_hfd<sve_fpimm_half_one, fpimm_half, fpimm_one, int_aarch64_sve_fsub>;
468473
defm FMUL_ZPZI : sve_fp_2op_i_p_zds_zeroing_hfd<sve_fpimm_half_two, fpimm_half, fpimm_two, int_aarch64_sve_fmul>;

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,11 +2767,19 @@ class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
27672767
let ElementSize = zprty.ElementSize;
27682768
}
27692769

2770-
multiclass sve_int_bin_pred_log<bits<3> opc, string asm, SDPatternOperator op> {
2771-
def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>;
2772-
def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>;
2773-
def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>;
2774-
def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>;
2770+
multiclass sve_int_bin_pred_log<bits<3> opc, string asm, string Ps,
2771+
SDPatternOperator op,
2772+
DestructiveInstTypeEnum flags> {
2773+
let DestructiveInstType = flags in {
2774+
def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>,
2775+
SVEPseudo2Instr<Ps # _B, 1>;
2776+
def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>,
2777+
SVEPseudo2Instr<Ps # _H, 1>;
2778+
def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>,
2779+
SVEPseudo2Instr<Ps # _S, 1>;
2780+
def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>,
2781+
SVEPseudo2Instr<Ps # _D, 1>;
2782+
}
27752783

27762784
def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
27772785
def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;

0 commit comments

Comments
 (0)