[PATCH] D78428: [MLIR] Make isPerfectlyNested check more efficient
    Uday Bondhugula via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Apr 18 11:49:58 PDT 2020
    
    
  
bondhugula marked 2 inline comments as done.
bondhugula added inline comments.
================
Comment at: mlir/lib/Transforms/Utils/LoopUtils.cpp:715
+  // We already know that the block can't be empty.
+  auto hasTwoElements = [](Block *block) {
+    auto secondOpIt = std::next(block->begin());
----------------
rriddle wrote:
> nit: You could use `llvm::hasNItems(block->begin(), block->end(), 2)`. We could also add a range based version to make it more usable.
This would lead to one extra conditional check since it wouldn't factor in the additional information that this block is known to have at least one element. But that method is useful in general - thanks.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78428/new/
https://reviews.llvm.org/D78428
    
    
More information about the llvm-commits
mailing list