[llvm] GlobalISel lane masks merging (PR #73337)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 12:50:20 PST 2023


================
@@ -207,7 +207,39 @@ bool AMDGPUInstructionSelector::selectCOPY(MachineInstr &I) const {
   return true;
 }
 
+bool isLaneMask(Register Reg, MachineRegisterInfo *MRI,
+                const SIRegisterInfo &TRI) {
+  if (MRI->getType(Reg) != LLT::scalar(1))
+    return false;
+  const TargetRegisterClass *RC = MRI->getRegClassOrNull(Reg);
+  if (!RC || !TRI.isSGPRClass(RC))
+    return false;
+
+  return true;
+}
+
+// PHI where all register operands are sgpr(register class) with S1 LLT.
+bool isLaneMaskPhi(MachineInstr &I, MachineRegisterInfo *MRI,
+                   const SIRegisterInfo &TRI) {
+  if (I.getOpcode() != AMDGPU::PHI)
----------------
nhaehnle wrote:

So the point is that if we see an `PHI` here (as opposed to a `G_PHI`), that's because it has already been selected.

Having this as a separate helper is confusing IMHO. Better to inline a check against `PHI` into `selectPHI`, and add an `assert` there that the defined register is a lane mask in that case.

https://github.com/llvm/llvm-project/pull/73337


More information about the llvm-commits mailing list