[Mlir-commits] [mlir] 13bc82b - [mlir] SCCP add missing pessimistic setting
Jacques Pienaar
llvmlistbot at llvm.org
Mon Jul 25 17:41:23 PDT 2022
Author: Jacques Pienaar
Date: 2022-07-25T17:41:17-07:00
New Revision: 13bc82b5873a234cb8f2af050a093b6710dbe17a
URL: https://github.com/llvm/llvm-project/commit/13bc82b5873a234cb8f2af050a093b6710dbe17a
DIFF: https://github.com/llvm/llvm-project/commit/13bc82b5873a234cb8f2af050a093b6710dbe17a.diff
LOG: [mlir] SCCP add missing pessimistic setting
When this was updated in D127139 the update in-place case was no longer
marked as pessimistic. Add back in.
Differential Revision: https://reviews.llvm.org/D130453
Added:
Modified:
mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
mlir/test/Transforms/sccp.mlir
mlir/test/lib/Dialect/Test/TestOps.td
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
index 386237e47b5e7..657157a5664f4 100644
--- a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp
@@ -67,6 +67,7 @@ void SparseConstantPropagation::visitOperation(
if (foldResults.empty()) {
op->setOperands(originalOperands);
op->setAttrs(originalAttrs);
+ markAllPessimisticFixpoint(results);
return;
}
diff --git a/mlir/test/Transforms/sccp.mlir b/mlir/test/Transforms/sccp.mlir
index b18763ad1ee4c..490809fd5d7d7 100644
--- a/mlir/test/Transforms/sccp.mlir
+++ b/mlir/test/Transforms/sccp.mlir
@@ -216,3 +216,19 @@ func.func @simple_produced_operand() -> (i32, i32) {
return %arg1, %arg2 : i32, i32
}
+
+// CHECK-LABEL: inplace_fold
+func.func @inplace_fold(%arg: i1) -> (i32) {
+ %0 = "test.op_in_place_fold_success"() : () -> 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
+}
+
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index afc8df3b276c2..038f49aeed456 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -1244,6 +1244,18 @@ def TestOpInPlaceFold : TEST_Op<"op_in_place_fold"> {
let hasFolder = 1;
}
+// Test op that simply returns success.
+def TestOpInPlaceFoldSuccess : TEST_Op<"op_in_place_fold_success"> {
+ let results = (outs Variadic<I1>);
+ let hasFolder = 1;
+ let extraClassDefinition = [{
+ ::mlir::LogicalResult $cppClass::fold(ArrayRef<Attribute> operands,
+ SmallVectorImpl<OpFoldResult> &results) {
+ return success();
+ }
+ }];
+}
+
// An op that always fold itself.
def TestPassthroughFold : TEST_Op<"passthrough_fold"> {
let arguments = (ins AnyType:$op);
More information about the Mlir-commits
mailing list