tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] zhiics commented on a change in pull request #5772: [ARITH]add simplify rule for div
Date Fri, 19 Jun 2020 00:10:34 GMT

zhiics commented on a change in pull request #5772:
URL: https://github.com/apache/incubator-tvm/pull/5772#discussion_r442565117



##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -353,6 +353,25 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const SubNode* op) {
         truncdiv(x + c1, c3) - truncdiv(x, c3), truncdiv(truncmod(x, c3) + c1, c3),
         CanProveGreaterEqual(x.Eval(), 0) && c1.Eval()->value >= 0 &&
c3.Eval()->value > 0);
 
+    TVM_TRY_REWRITE_IF(truncdiv(x * c1 + c2, c3) - truncdiv(x * c1 + c4, c3), truncdiv(c2
- c4, c3),
+                       c1.Eval()->value >= 0 && c2.Eval()->value > 0
&& c3.Eval()->value > 0 &&
+                           c4.Eval()->value >= 0 && CanProveGreaterEqual(x.Eval(),
0) &&
+                           std::abs(c4.Eval()->value - c2.Eval()->value) >= c3.Eval()->value);

Review comment:
       hmm, is this always true again?
   
   say `c1 = 0, c2 = 6, c3 = 3, c4 = 2`, `c4 - c2 = 4 > 3`
   `truncdiv(x * c1 + c2, c3) - truncdiv(x * c1 + c4, c3) = truncdiv(6, 3) - truncdiv(2, 3)`
   `truncdiv(c2 - c4, c3) = truncdiv(4, 3)`
   




----------------------------------------------------------------
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.

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



Mime
View raw message