-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[AArch64][llvm] (NFC) Refactor sve_intx_dot
class and delete sve2p1_two_way_dot_vv
#160103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-aarch64 Author: Jonathan Thackray (jthackray) Changes
Full diff: https://github.com/llvm/llvm-project/pull/160103.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index 7913e8ca8652e..0b50ba5425704 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -3748,18 +3748,18 @@ multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm,
// SVE Integer Dot Product Group
//===----------------------------------------------------------------------===//
-class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
- ZPRRegOp zprty2>
+class sve_intx_dot<bits<2> sz, bits<5> op5, bit U, string asm,
+ ZPRRegOp zprty1, ZPRRegOp zprty2>
: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
"\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
bits<5> Zda;
bits<5> Zn;
bits<5> Zm;
- let Inst{31-23} = 0b010001001;
- let Inst{22} = sz;
+ let Inst{31-24} = 0b01000100;
+ let Inst{23-22} = sz;
let Inst{21} = 0;
let Inst{20-16} = Zm;
- let Inst{15-11} = 0;
+ let Inst{15-11} = op5;
let Inst{10} = U;
let Inst{9-5} = Zn;
let Inst{4-0} = Zda;
@@ -3770,13 +3770,19 @@ class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
}
multiclass sve_intx_dot<bit opc, string asm, SDPatternOperator op> {
- def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
- def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
+ def _S : sve_intx_dot<0b10, 0b00000, opc, asm, ZPR32, ZPR8>;
+ def _D : sve_intx_dot<0b11, 0b00000, opc, asm, ZPR64, ZPR16>;
def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _S)>;
def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _D)>;
}
+multiclass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
+ def NAME : sve_intx_dot<0b00, 0b11001, u, mnemonic, ZPR32, ZPR16>;
+
+ def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
+}
+
//===----------------------------------------------------------------------===//
// SVE Integer Dot Product Group - Indexed Group
//===----------------------------------------------------------------------===//
@@ -9893,32 +9899,6 @@ multiclass sve_fp_clamp_bfloat<string asm, SDPatternOperator op> {
def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
}
-// SVE two-way dot product
-class sve2p1_two_way_dot_vv<string mnemonic, bit u>
- : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
- mnemonic, "\t$Zda, $Zn, $Zm",
- "", []>, Sched<[]> {
- bits<5> Zda;
- bits<5> Zn;
- bits<5> Zm;
- let Inst{31-21} = 0b01000100000;
- let Inst{20-16} = Zm;
- let Inst{15-11} = 0b11001;
- let Inst{10} = u;
- let Inst{9-5} = Zn;
- let Inst{4-0} = Zda;
-
- let Constraints = "$Zda = $_Zda";
- let DestructiveInstType = DestructiveOther;
- let hasSideEffects = 0;
-}
-
-multiclass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
- def NAME : sve2p1_two_way_dot_vv<mnemonic, u>;
-
- def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
-}
-
// SVE two-way dot product (indexed)
class sve2p1_two_way_dot_vvi<string mnemonic, bit u>
: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS32b:$i2),
|
Since we are already merging these 2, we might as well merge both multiclasses together as well. These are the same instructions, its just that intx_dot variants do 4 way sdot while two_way do 2 way sdot. I don't think there is a reason to have separate multiclass for that. |
Thanks, good idea. I tried this, and it looks nice. However, they require different predicates ( |
…1_two_way_dot_vv` `sve_intx_dot` and `sve2p1_two_way_dot_vv` are both very similar, encoding for `SDOT` instructions. Refactor the `sve_intx_dot` class so it is more flexible, and delete the `sve2p1_two_way_dot_vv` class. Making this change now, to accommodate future SDOT instructions.
9fd0600
to
2bd1bfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah missed that. LGTM then
…1_two_way_dot_vv` (llvm#160103) `sve_intx_dot` and `sve2p1_two_way_dot_vv` are both very similar, encoding for `SDOT` instructions. Refactor the `sve_intx_dot` class so it is more flexible, and delete the `sve2p1_two_way_dot_vv` class. Making this change now, to accommodate future SDOT instructions.
sve_intx_dot
andsve2p1_two_way_dot_vv
are both very similar, encoding forSDOT
instructions. Refactor thesve_intx_dot
class so it is more flexible, and delete thesve2p1_two_way_dot_vv
class.Making this change now, to accommodate future SDOT instructions.