[Mlir-commits] [mlir] [mlir][NVVM] Add support for barrier0 operation with predicate (PR #167036)

Durgadoss R llvmlistbot at llvm.org
Mon Nov 10 05:16:57 PST 2025


================
@@ -1007,31 +1025,36 @@ def NVVM_BarrierOp : NVVM_Op<"barrier", [AttrSizedOperandSegments]> {
     [For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-bar)
   }];
 
-  let arguments = (ins     
-    Optional<I32>:$barrierId,
-    Optional<I32>:$numberOfThreads);
+  let arguments = (ins Optional<I32>:$barrierId, Optional<I32>:$numberOfThreads,
+      OptionalAttr<BarrierReductionAttr>:$reductionOp,
+      Optional<I32>:$reductionPredicate);
   string llvmBuilder = [{
     llvm::Value *id = $barrierId ? $barrierId : builder.getInt32(0);
     if ($numberOfThreads)
       createIntrinsicCall(
           builder, llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_count,
           {id, $numberOfThreads});
+    else if ($reductionOp)
+      createIntrinsicCall(
+          builder, getBarrierIntrinsicID($reductionOp), {$reductionPredicate});
     else
       createIntrinsicCall(
           builder, llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_all, {id});
----------------
durga4github wrote:

Since this llvmBuilder is getting complex, can we do it instead as `getIntrinsicIDAndArgs()` methods?
(There are many Ops that use this kind of pattern that you can use as a reference)

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


More information about the Mlir-commits mailing list