You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2023/01/10 14:12:45 UTC

[GitHub] [tvm] Lunderberg commented on a diff in pull request #13724: [Arith] Use ConstIntBound to remove negative numerator when lowering

Lunderberg commented on code in PR #13724:
URL: https://github.com/apache/tvm/pull/13724#discussion_r1065832687


##########
src/tir/transforms/lower_intrin.cc:
##########
@@ -112,20 +113,33 @@ class IntrinInjecter : public tvm::arith::IRMutatorWithAnalyzer {
       // Common path, positive divisor
       if (analyzer_->CanProveGreaterEqual(op->a, 0) || analyzer_->CanProveGreaterEqual(e, 0)) {
         return truncdiv(op->a, op->b);
+      }
+
+      // If the numerator's lower bound is known, express the floordiv
+      // in terms of truncdiv using only positive operands.
+      arith::ConstIntBound const_int_bound = analyzer_->const_int_bound(op->a);
+      if (const_int_bound->min_value != arith::ConstIntBound::kNegInf &&
+          const_int_bound->min_value < 0 &&
+          const_int_bound->min_value > -(1LL << (op->a->dtype.bits() - 1))) {

Review Comment:
   Thank you, and op.h's `min_value` is exactly what I had been looking for.  I had checked whether `ConstIntBound::Everything(dtype)` was public, but wasn't aware of `min_value`.  PR updated to use `min_value` instead of doing the calculation here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org