Skip to content

Commit aa7f3fa

Browse files
committed
break if replacement found
1 parent c20f637 commit aa7f3fa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mlir/lib/Reducer/ReductionTreePass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ static void applyPatterns(Region &region,
6868
size_t index = operandTie.index();
6969
auto operand = operandTie.value();
7070
for (auto candidate : valueMap[operand.getType()])
71-
if (domInfo.properlyDominates(candidate, op))
71+
if (domInfo.properlyDominates(candidate, op)) {
7272
op->setOperand(index, candidate);
73+
break;
74+
}
7375
}
7476

7577
// `applyOpPatternsGreedily` with folding returns whether the op is

mlir/test/mlir-reduce/replace-operands.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// CHECK-LABEL: func.func @main
55
func.func @main() {
6-
// CHECK-NEXT: %[[RESULT:.*]] = arith.constant 2 : i32
6+
// CHECK-NEXT: %[[RESULT:.*]] = arith.constant 3 : i32
77
// CHECK-NEXT: {{.*}} = "test.op_crash"(%[[RESULT]], %[[RESULT]]) : (i32, i32) -> i32
88
// CHECK-NEXT return
99

0 commit comments

Comments
 (0)