diff --git a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp --- a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp @@ -38,8 +38,10 @@ // 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 constantOperands; constantOperands.reserve(op->getNumOperands()); diff --git a/mlir/test/Transforms/sccp.mlir b/mlir/test/Transforms/sccp.mlir --- a/mlir/test/Transforms/sccp.mlir +++ b/mlir/test/Transforms/sccp.mlir @@ -218,7 +218,7 @@ } // 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 @@ ^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 +}