Skip to content

Commit 39ac64c

Browse files
authored
[mlir][Arith] ValueBoundsInterface: speedup arith.select (#113531)
When calculating value bounds in the arith.select op , the compare function is invoked to compare trueValue and falseValue. This function rebuilds constraints, resulting in repeated computations of value bounds. In large-scale programs, this redundancy significantly impacts compilation time.
1 parent 7ad63c0 commit 39ac64c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ struct SelectOpInterface
107107
// If trueValue <= falseValue:
108108
// * result <= falseValue
109109
// * result >= trueValue
110-
if (cstr.compare(/*lhs=*/{trueValue, dim},
111-
ValueBoundsConstraintSet::ComparisonOperator::LE,
112-
/*rhs=*/{falseValue, dim})) {
110+
if (cstr.populateAndCompare(
111+
/*lhs=*/{trueValue, dim},
112+
ValueBoundsConstraintSet::ComparisonOperator::LE,
113+
/*rhs=*/{falseValue, dim})) {
113114
if (dim) {
114115
cstr.bound(value)[*dim] >= cstr.getExpr(trueValue, dim);
115116
cstr.bound(value)[*dim] <= cstr.getExpr(falseValue, dim);
@@ -121,9 +122,10 @@ struct SelectOpInterface
121122
// If falseValue <= trueValue:
122123
// * result <= trueValue
123124
// * result >= falseValue
124-
if (cstr.compare(/*lhs=*/{falseValue, dim},
125-
ValueBoundsConstraintSet::ComparisonOperator::LE,
126-
/*rhs=*/{trueValue, dim})) {
125+
if (cstr.populateAndCompare(
126+
/*lhs=*/{falseValue, dim},
127+
ValueBoundsConstraintSet::ComparisonOperator::LE,
128+
/*rhs=*/{trueValue, dim})) {
127129
if (dim) {
128130
cstr.bound(value)[*dim] >= cstr.getExpr(falseValue, dim);
129131
cstr.bound(value)[*dim] <= cstr.getExpr(trueValue, dim);

0 commit comments

Comments
 (0)