[Mlir-commits] [mlir] 052669e - [mlir] add missing pessimistic setting

Jacques Pienaar llvmlistbot at llvm.org
Wed Aug 17 16:21:21 PDT 2022


Author: Jacques Pienaar
Date: 2022-08-17T16:20:13-07:00
New Revision: 052669e71ab99b095ccdbc40d633018b53a75f15

URL: https://github.com/llvm/llvm-project/commit/052669e71ab99b095ccdbc40d633018b53a75f15
DIFF: https://github.com/llvm/llvm-project/commit/052669e71ab99b095ccdbc40d633018b53a75f15.diff

LOG: [mlir] add missing pessimistic setting

This is updated on https://reviews.llvm.org/D127139, to mark op with region as pessimistic.

Reviewed By: jpienaar

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

Added: 
    

Modified: 
    mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
    mlir/test/Transforms/sccp.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
index 657157a5664f4..19d0b7d0f5f70 100644
--- a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
@@ -38,8 +38,10 @@ void SparseConstantPropagation::visitOperation(
   // guarantee that folding will be out-of-place. We don't allow in-place
   // folds as the desire here is for simulated execution, and not general
   // folding.
-  if (op->getNumRegions())
+  if (op->getNumRegions()) {
+    markAllPessimisticFixpoint(results);
     return;
+  }
 
   SmallVector<Attribute, 8> constantOperands;
   constantOperands.reserve(op->getNumOperands());

diff  --git a/mlir/test/Transforms/sccp.mlir b/mlir/test/Transforms/sccp.mlir
index 2c7f5711f7d49..d4ca3a2b492a3 100644
--- a/mlir/test/Transforms/sccp.mlir
+++ b/mlir/test/Transforms/sccp.mlir
@@ -218,7 +218,7 @@ func.func @simple_produced_operand() -> (i32, i32) {
 }
 
 // CHECK-LABEL: inplace_fold
-func.func @inplace_fold(%arg: i1) -> (i32) {
+func.func @inplace_fold() -> (i32) {
   %0 = "test.op_in_place_fold_success"() : () -> i1
   %1 = arith.constant 5 : i32
   cf.cond_br %0, ^a, ^b
@@ -231,3 +231,18 @@ func.func @inplace_fold(%arg: i1) -> (i32) {
 ^b:
   return %1 : i32
 }
+
+// CHECK-LABEL: op_with_region
+func.func @op_with_region() -> (i32) {
+  %0 = "test.op_with_region"() ({}) : () -> i1
+  %1 = arith.constant 5 : i32
+  cf.cond_br %0, ^a, ^b
+
+^a:
+  // CHECK-NOT: addi
+  %3 = arith.addi %1, %1 : i32
+  return %3 : i32
+
+^b:
+  return %1 : i32
+}


        


More information about the Mlir-commits mailing list