[PATCH] D114700: AMDGPU/GlobalISel: Fix constant bus restriction errors for med3

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 11:21:32 PST 2021


arsenm added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp:136
   B.setInstrAndDebugLoc(MI);
-  B.buildInstr(MatchInfo.Opc, {MI.getOperand(0)},
-               {MatchInfo.Val0, MatchInfo.Val1, MatchInfo.Val2}, MI.getFlags());
+  const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
+  unsigned ConstantBusLimit = ST.getConstantBusLimit(MatchInfo.Opc);
----------------
The subtarget should probably be cached in the combiner helper


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp:137
+  const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
+  unsigned ConstantBusLimit = ST.getConstantBusLimit(MatchInfo.Opc);
+  SmallVector<Register, 3> Regs(
----------------
My intention was globalisel should not need to think about the constant bus restriction at all because it will be quickly become unmanageable. All code would need to be exactly aware of how the instructions will be selected, which is impossible.

All VALU instructions should use all VGPR (or VCC) mappings


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp:148
+    }
+    if (NumSgprUsed >= ConstantBusLimit) {
+      auto CopyToVgpr = B.buildCopy(MRI.getType(Regs[i]), Regs[i]);
----------------
Should not consider individual mappings, everything just needs to be VGPR


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp:149-152
+      auto CopyToVgpr = B.buildCopy(MRI.getType(Regs[i]), Regs[i]);
+      MRI.setRegBank(CopyToVgpr.getReg(0),
+                     RBI.getRegBank(AMDGPU::VGPRRegBankID));
+      SrcOps.push_back(CopyToVgpr.getReg(0));
----------------
Probably should have a constrain or copy to VGPR helper


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114700/new/

https://reviews.llvm.org/D114700



More information about the llvm-commits mailing list