[clang] [llvm] [HLSL] Implement WaveActiveAnyTrue intrinsic (PR #115902)

Greg Roth via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 15 11:36:42 PST 2024


================
@@ -1949,6 +1952,22 @@ bool SPIRVInstructionSelector::selectSign(Register ResVReg,
   return Result;
 }
 
+bool SPIRVInstructionSelector::selectWaveActiveAnyTrue(Register ResVReg,
+                                                       const SPIRVType *ResType,
+                                                       MachineInstr &I) const {
+  assert(I.getNumOperands() == 3);
+  assert(I.getOperand(2).isReg());
+
+  MachineBasicBlock &BB = *I.getParent();
+  SPIRVType *IntTy = GR.getOrCreateSPIRVIntegerType(32, I, TII);
+
+  return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpGroupNonUniformAny))
+      .addDef(ResVReg)
+      .addUse(GR.getSPIRVTypeID(ResType))
+      .addUse(GR.getOrCreateConstInt(SPIRV::Scope::Subgroup, I, IntTy, TII))
+      .addUse(I.getOperand(2).getReg());
----------------
pow2clk wrote:

I see there are still a few instances below where we return the result of `addUse` as a boolean result, but it should really have one more method call to `constrainAllUses` at the end as should the ones below. 
```suggestion
      .addUse(I.getOperand(2).getReg())
      .constrainAllUses(TII, TRI, RBI);
```

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


More information about the cfe-commits mailing list