[Mlir-commits] [mlir] [mlir][gpu] Add address space modifier to gpu.barrier (PR #177425)
Alan Li
llvmlistbot at llvm.org
Thu Jan 22 18:46:06 PST 2026
================
@@ -1472,18 +1472,45 @@ LogicalResult RotateOp::verify() {
/// Remove gpu.barrier after gpu.barrier, the threads are already synchronized!
static LogicalResult eraseRedundantGpuBarrierOps(BarrierOp op,
PatternRewriter &rewriter) {
- if (isa_and_nonnull<BarrierOp>(op->getNextNode())) {
- rewriter.eraseOp(op);
- return success();
+ auto nextOp = dyn_cast_or_null<BarrierOp>(op->getNextNode());
+ if (!nextOp)
+ return failure();
+
+ std::optional<ArrayAttr> thisMemfence = op.getAddressSpaces();
+ std::optional<ArrayAttr> nextMemfence = nextOp.getAddressSpaces();
+
+ if (thisMemfence) {
+ rewriter.modifyOpInPlace(op, [&]() {
+ if (!nextMemfence) {
+ op.removeAddressSpacesAttr();
+ return;
+ }
+ // Fast path - mergge where the two barriers fence the same spaces.
----------------
lialan wrote:
```suggestion
// Fast path - merge where the two barriers fence the same spaces.
```
https://github.com/llvm/llvm-project/pull/177425
More information about the Mlir-commits
mailing list