[llvm] [AMDGPU] misched: avoid subregister dependencies (PR #140255)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 17:54:28 PST 2025
================
@@ -627,6 +627,124 @@ GCNSubtarget::getMaxNumVectorRegs(const Function &F) const {
return std::pair(MaxNumVGPRs, MaxNumAGPRs);
}
+// Check to which source operand UseOpIdx points to and return a pointer to the
+// operand of the corresponding source modifier.
+// Return nullptr if UseOpIdx either doesn't point to src0/1/2 or if there is no
+// operand for the corresponding source modifier.
+static const MachineOperand *
+getVOP3PSourceModifierFromOpIdx(const MachineInstr *UseI, int UseOpIdx,
+ const SIInstrInfo &InstrInfo) {
+ AMDGPU::OpName UseModName;
+ AMDGPU::OpName UseName =
+ AMDGPU::getOperandIdxName(UseI->getOpcode(), UseOpIdx);
+ switch (UseName) {
+ case AMDGPU::OpName::src0:
+ UseModName = AMDGPU::OpName::src0_modifiers;
+ break;
+ case AMDGPU::OpName::src1:
+ UseModName = AMDGPU::OpName::src1_modifiers;
+ break;
+ case AMDGPU::OpName::src2:
+ UseModName = AMDGPU::OpName::src2_modifiers;
+ break;
+ default:
+ return nullptr;
+ }
+ return InstrInfo.getNamedOperand(*UseI, UseModName);
+}
+
+// Get the subreg idx of the subreg that is used by the given instruction
+// operand, considering the given op_sel modifier.
+// Return 0 if the whole register is used or as a conservative fallback.
+static unsigned getEffectiveSubRegIdx(const SIRegisterInfo &TRI,
+ const SIInstrInfo &InstrInfo,
+ const MachineOperand &Op) {
+ const MachineInstr *I = Op.getParent();
+ if (!InstrInfo.isVOP3P(*I) || InstrInfo.isWMMA(*I) || InstrInfo.isSWMMAC(*I))
+ return 0;
----------------
arsenm wrote:
```suggestion
return AMDGPU::NoSubRegister;
```
https://github.com/llvm/llvm-project/pull/140255
More information about the llvm-commits
mailing list