[llvm] GlobalISel lane masks merging (PR #73337)
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 05:39:05 PST 2023
================
@@ -207,9 +207,31 @@ 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);
+ return RC && TRI.isSGPRClass(RC);
+}
+
bool AMDGPUInstructionSelector::selectPHI(MachineInstr &I) const {
const Register DefReg = I.getOperand(0).getReg();
const LLT DefTy = MRI->getType(DefReg);
+ // Lane mask PHIs, PHI where all register operands have sgpr register class
+ // with S1 LLT, are already selected in divergence lowering pass.
+ if (I.getOpcode() == AMDGPU::PHI && isLaneMask(DefReg, MRI, TRI)) {
----------------
petar-avramovic wrote:
There is one regression test with PHI in `phi_s32_ss_sbranch - GlobalISel/inst-select-phi.mir `. It can be disabled. Other then that assert is fine.
I wanted to check isLaneMask for all operand, can I bring helper function back then? it would look like this without helper
```
if (I.getOpcode() == AMDGPU::PHI) {
assert(isLaneMask(DefReg, MRI, TRI));
for (unsigned i = 1, e = I.getNumOperands(); i != e; e += 2)
assert(isLaneMask(I.getOperand(i).getReg(), MRI, TRI));
return true;
}
```
https://github.com/llvm/llvm-project/pull/73337
More information about the llvm-commits
mailing list