[llvm] [AArch64][SME2] Add FORM_STRIDED_TUPLE pseudo nodes (PR #116399)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 09:48:39 PST 2024
================
@@ -8641,6 +8641,57 @@ static bool checkZExtBool(SDValue Arg, const SelectionDAG &DAG) {
return ZExtBool;
}
+// The FORM_TRANSPOSED_REG_TUPLE pseudo should only be used if the
+// input operands are copy nodes where the source register is in a
+// StridedOrContiguous class. For example:
+//
+// %3:zpr2stridedorcontiguous = LD1B_2Z_IMM_PSEUDO ..
+// %4:zpr = COPY %3.zsub1:zpr2stridedorcontiguous
+// %5:zpr = COPY %3.zsub0:zpr2stridedorcontiguous
+// %6:zpr2stridedorcontiguous = LD1B_2Z_PSEUDO ..
+// %7:zpr = COPY %6.zsub1:zpr2stridedorcontiguous
+// %8:zpr = COPY %6.zsub0:zpr2stridedorcontiguous
+// %9:zpr2mul2 = FORM_TRANSPOSED_REG_TUPLE_X2_PSEUDO %5:zpr, %8:zpr
+//
+bool shouldUseFormStridedPseudo(MachineInstr &MI) {
+ MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
+
+ MCRegister SubReg = MCRegister::NoRegister;
+ for (unsigned I = 1; I < MI.getNumOperands(); ++I) {
+ MachineOperand &MO = MI.getOperand(I);
+ assert(MO.isReg() && "Unexpected operand to FORM_TRANSPOSED_REG_TUPLE");
+
+ MachineOperand *Def = MRI.getOneDef(MO.getReg());
+ if (!Def || !Def->getParent()->isCopy())
+ return false;
+
+ const MachineOperand &CpySrc = Def->getParent()->getOperand(1);
+ MachineOperand *CopySrcOp = MRI.getOneDef(CpySrc.getReg());
+ unsigned OpSubReg = CpySrc.getSubReg();
+ if (SubReg == MCRegister::NoRegister)
+ SubReg = OpSubReg;
+ if (!CopySrcOp || !CopySrcOp->isReg() || OpSubReg != SubReg)
+ return false;
+
+ const TargetRegisterClass *RegClass = nullptr;
+ switch (MI.getNumOperands() - 1) {
----------------
sdesmalen-arm wrote:
Could you hoist this out of the loop, and also just switch on the opcode, rather than the number of operands? (then you can add a `llvm_unreachable` for the case where the opcode is unexpected).
https://github.com/llvm/llvm-project/pull/116399
More information about the llvm-commits
mailing list