[Mlir-commits] [mlir] 39ac64c - [mlir][Arith] ValueBoundsInterface: speedup arith.select (#113531)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Oct 27 19:14:47 PDT 2024


Author: donald chen
Date: 2024-10-28T10:14:44+08:00
New Revision: 39ac64c1c0fc61a476aa22c53e6977608ead03cf

URL: https://github.com/llvm/llvm-project/commit/39ac64c1c0fc61a476aa22c53e6977608ead03cf
DIFF: https://github.com/llvm/llvm-project/commit/39ac64c1c0fc61a476aa22c53e6977608ead03cf.diff

LOG: [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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index 7cfcc4180539c2..6de151594e3e9c 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -107,9 +107,10 @@ struct SelectOpInterface
     // If trueValue <= falseValue:
     // * result <= falseValue
     // * result >= trueValue
-    if (cstr.compare(/*lhs=*/{trueValue, dim},
-                     ValueBoundsConstraintSet::ComparisonOperator::LE,
-                     /*rhs=*/{falseValue, dim})) {
+    if (cstr.populateAndCompare(
+            /*lhs=*/{trueValue, dim},
+            ValueBoundsConstraintSet::ComparisonOperator::LE,
+            /*rhs=*/{falseValue, dim})) {
       if (dim) {
         cstr.bound(value)[*dim] >= cstr.getExpr(trueValue, dim);
         cstr.bound(value)[*dim] <= cstr.getExpr(falseValue, dim);
@@ -121,9 +122,10 @@ struct SelectOpInterface
     // If falseValue <= trueValue:
     // * result <= trueValue
     // * result >= falseValue
-    if (cstr.compare(/*lhs=*/{falseValue, dim},
-                     ValueBoundsConstraintSet::ComparisonOperator::LE,
-                     /*rhs=*/{trueValue, dim})) {
+    if (cstr.populateAndCompare(
+            /*lhs=*/{falseValue, dim},
+            ValueBoundsConstraintSet::ComparisonOperator::LE,
+            /*rhs=*/{trueValue, dim})) {
       if (dim) {
         cstr.bound(value)[*dim] >= cstr.getExpr(falseValue, dim);
         cstr.bound(value)[*dim] <= cstr.getExpr(trueValue, dim);


        


More information about the Mlir-commits mailing list