[Mlir-commits] [mlir] [mlir] Use llvm::hasSingleElement (NFC) (PR #133648)

Kazu Hirata llvmlistbot at llvm.org
Sun Mar 30 11:23:27 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/133648

None

>From 20e5fddbf3a64e64c993de9b2f2975ebdfaf66fe Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 23 Mar 2025 18:54:39 -0700
Subject: [PATCH] [mlir] Use llvm::hasSingleElement (NFC)

---
 mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp
index bcfd7ebccd12d..2959d67b366b9 100644
--- a/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp
@@ -255,8 +255,7 @@ static bool hasOneBranchOpTo(Block &srcBlock, Block &dstBlock) {
 
 /// Returns true if the given `block` only contains one `spirv.mlir.merge` op.
 static bool isMergeBlock(Block &block) {
-  return !block.empty() && std::next(block.begin()) == block.end() &&
-         isa<spirv::MergeOp>(block.front());
+  return llvm::hasSingleElement(block) && isa<spirv::MergeOp>(block.front());
 }
 
 /// Returns true if a `spirv.mlir.merge` op outside the merge block.



More information about the Mlir-commits mailing list