[Mlir-commits] [mlir] 6e60bb6 - [mlir:DataFlowAnalysis] Reprocess the arguments of already executable edges

River Riddle llvmlistbot at llvm.org
Wed Sep 22 13:16:11 PDT 2021


Author: River Riddle
Date: 2021-09-22T20:14:55Z
New Revision: 6e60bb6883178cf14e6fd47a6789495636e4322f

URL: https://github.com/llvm/llvm-project/commit/6e60bb6883178cf14e6fd47a6789495636e4322f
DIFF: https://github.com/llvm/llvm-project/commit/6e60bb6883178cf14e6fd47a6789495636e4322f.diff

LOG: [mlir:DataFlowAnalysis] Reprocess the arguments of already executable edges

This fixes a bug where we discover new information about the arguments of an
already executable edge, but don't visit the arguments. We only visit the arguments, and not the block itself, so this commit shouldn't really affect performance at all.

Fixes PR#51871

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

Added: 
    

Modified: 
    mlir/lib/Analysis/DataFlowAnalysis.cpp
    mlir/test/Transforms/sccp.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/DataFlowAnalysis.cpp b/mlir/lib/Analysis/DataFlowAnalysis.cpp
index b5a5e17fd2c35..b91d2de602fe7 100644
--- a/mlir/lib/Analysis/DataFlowAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlowAnalysis.cpp
@@ -722,8 +722,7 @@ bool ForwardDataFlowSolver::isBlockExecutable(Block *block) const {
 }
 
 void ForwardDataFlowSolver::markEdgeExecutable(Block *from, Block *to) {
-  if (!executableEdges.insert(std::make_pair(from, to)).second)
-    return;
+  executableEdges.insert(std::make_pair(from, to));
 
   // Mark the destination as executable, and reprocess its arguments if it was
   // already executable.

diff  --git a/mlir/test/Transforms/sccp.mlir b/mlir/test/Transforms/sccp.mlir
index 39d9acd7bf042..29499f3bb173b 100644
--- a/mlir/test/Transforms/sccp.mlir
+++ b/mlir/test/Transforms/sccp.mlir
@@ -178,3 +178,23 @@ func @simple_loop_overdefined(%arg0 : i32, %cond1 : i1) -> i32 {
 
   return %arg : i32
 }
+
+// Check that we reprocess executable edges when information changes.
+
+// CHECK-LABEL: func @recheck_executable_edge
+func @recheck_executable_edge(%cond0: i1) -> (i1, i1) {
+  %true = constant true
+  %false = constant false
+  cond_br %cond0, ^bb_1a, ^bb2(%false : i1)
+^bb_1a:
+  br ^bb2(%true : i1)
+
+^bb2(%x: i1):
+  // CHECK: ^bb2(%[[X:.*]]: i1):
+  br ^bb3(%x : i1)
+
+^bb3(%y: i1):
+  // CHECK: ^bb3(%[[Y:.*]]: i1):
+  // CHECK: return %[[X]], %[[Y]]
+  return %x, %y : i1, i1
+}


        


More information about the Mlir-commits mailing list