[clang] [llvm] [HLSL][DXIL][SPRIV] Added `GroupMemoryBarrier()` (PR #185383)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:02:42 PDT 2026


================
@@ -4162,18 +4184,10 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
     return selectFirstBitHigh(ResVReg, ResType, I, /*IsSigned=*/true);
   case Intrinsic::spv_firstbitlow: // There is no CL equivlent of FindILsb
     return selectFirstBitLow(ResVReg, ResType, I);
-  case Intrinsic::spv_group_memory_barrier_with_group_sync: {
-    Register MemSemReg =
-        buildI32Constant(SPIRV::MemorySemantics::SequentiallyConsistent, I);
-    Register ScopeReg = buildI32Constant(SPIRV::Scope::Workgroup, I);
-    MachineBasicBlock &BB = *I.getParent();
-    BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpControlBarrier))
-        .addUse(ScopeReg)
-        .addUse(ScopeReg)
-        .addUse(MemSemReg)
-        .constrainAllUses(TII, TRI, RBI);
-    return true;
-  }
+  case Intrinsic::spv_group_memory_barrier:
+    return selectBarrierInst(I, SPIRV::Scope::Workgroup, false);
+  case Intrinsic::spv_group_memory_barrier_with_group_sync:
+    return selectBarrierInst(I, SPIRV::Scope::Workgroup, true);
----------------
farzonl wrote:

Just add a comment so we know what the bool refers to.
```suggestion
    return selectBarrierInst(I, SPIRV::Scope::Workgroup, /*WithGroupSync*/, false);
  case Intrinsic::spv_group_memory_barrier_with_group_sync:
    return selectBarrierInst(I, SPIRV::Scope::Workgroup,  /*WithGroupSync*/true);
```

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


More information about the llvm-commits mailing list