[Mlir-commits] [mlir] 67d0e79 - [Dominance] Speed up recalculate noticable, NFC.

Chris Lattner llvmlistbot at llvm.org
Sat May 29 10:50:57 PDT 2021


Author: Chris Lattner
Date: 2021-05-29T10:50:22-07:00
New Revision: 67d0e79b1f41256ac99e4aa0b88ce2cd7865f960

URL: https://github.com/llvm/llvm-project/commit/67d0e79b1f41256ac99e4aa0b88ce2cd7865f960
DIFF: https://github.com/llvm/llvm-project/commit/67d0e79b1f41256ac99e4aa0b88ce2cd7865f960.diff

LOG: [Dominance] Speed up recalculate noticable, NFC.

This avoids trying to find the RegionKindInterface for every
operation in the program, we only need it if they have regions.

Differential Revision: https://reviews.llvm.org/D103367

Added: 
    

Modified: 
    mlir/lib/IR/Dominance.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Dominance.cpp b/mlir/lib/IR/Dominance.cpp
index 16c98d6bc679..c13a57dbf300 100644
--- a/mlir/lib/IR/Dominance.cpp
+++ b/mlir/lib/IR/Dominance.cpp
@@ -27,7 +27,8 @@ template class llvm::DomTreeNodeBase<Block>;
 /// Return true if the region with the given index inside the operation
 /// has SSA dominance.
 static bool hasSSADominance(Operation *op, unsigned index) {
-  if (!op->isRegistered()) return false;
+  if (!op->isRegistered())
+    return false;
 
   auto kindInterface = dyn_cast<RegionKindInterface>(op);
   return !kindInterface || kindInterface.hasSSADominance(index);
@@ -43,8 +44,11 @@ void DominanceInfoBase<IsPostDom>::recalculate(Operation *op) {
 
   // Build the dominance for each of the operation regions.
   op->walk([&](Operation *op) {
-    auto kindInterface = dyn_cast<RegionKindInterface>(op);
     unsigned numRegions = op->getNumRegions();
+    if (numRegions == 0)
+      return;
+
+    auto kindInterface = dyn_cast<RegionKindInterface>(op);
     for (unsigned i = 0; i < numRegions; i++) {
       Region &region = op->getRegion(i);
       // Don't compute dominance if the region is empty.


        


More information about the Mlir-commits mailing list