[Mlir-commits] [mlir] 1d9ad99 - [mlir] Use llvm::hasSingleElement (NFC) (#133881)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Apr 1 03:58:54 PDT 2025


Author: Longsheng Mou
Date: 2025-04-01T18:58:50+08:00
New Revision: 1d9ad99305753a11a28e61edb130d9c63859f42e

URL: https://github.com/llvm/llvm-project/commit/1d9ad99305753a11a28e61edb130d9c63859f42e
DIFF: https://github.com/llvm/llvm-project/commit/1d9ad99305753a11a28e61edb130d9c63859f42e.diff

LOG: [mlir] Use llvm::hasSingleElement (NFC) (#133881)

Added: 
    

Modified: 
    mlir/lib/IR/Block.cpp
    mlir/lib/Transforms/Utils/InliningUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index 4b1568219fb37..959a60c044502 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -119,7 +119,7 @@ bool Block::verifyOpOrder() {
   if (!isOpOrderValid())
     return false;
   // The order is valid if there are less than 2 operations.
-  if (operations.empty() || std::next(operations.begin()) == operations.end())
+  if (operations.empty() || llvm::hasSingleElement(operations))
     return false;
 
   Operation *prev = nullptr;

diff  --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp
index a8bf34cdb3e02..e113389b26ae7 100644
--- a/mlir/lib/Transforms/Utils/InliningUtils.cpp
+++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp
@@ -330,7 +330,7 @@ inlineRegionImpl(InlinerInterface &interface, Region *src, Block *inlineBlock,
   bool singleBlockFastPath = interface.allowSingleBlockOptimization(newBlocks);
 
   // Handle the case where only a single block was inlined.
-  if (singleBlockFastPath && std::next(newBlocks.begin()) == newBlocks.end()) {
+  if (singleBlockFastPath && llvm::hasSingleElement(newBlocks)) {
     // Run the result attribute handler on the terminator operands.
     Operation *firstBlockTerminator = firstNewBlock->getTerminator();
     builder.setInsertionPoint(firstBlockTerminator);


        


More information about the Mlir-commits mailing list