tqchen commented on a change in pull request #5924:
URL: https://github.com/apache/incubator-tvm/pull/5924#discussion_r445642433



##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -722,8 +728,15 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
FloorDivNode* op) {
       ModularSet bmod = analyzer_->modular_set(b1.Eval());
       int64_t ramp_min = floordiv(bmod->base, c2val);
       int64_t ramp_max = floordiv(bmod->base + (lanes.Eval() - 1) * c1val, 
c2val);
-      if (bmod->coeff % c2val == 0 && ramp_min == ramp_max) {
-        return broadcast(floordiv(b1, c2), lanes).Eval();
+      if (ramp_min == ramp_max) {
+        // If b1 can device c2

Review comment:
       device-> divide

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -722,8 +728,15 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
FloorDivNode* op) {
       ModularSet bmod = analyzer_->modular_set(b1.Eval());
       int64_t ramp_min = floordiv(bmod->base, c2val);
       int64_t ramp_max = floordiv(bmod->base + (lanes.Eval() - 1) * c1val, 
c2val);
-      if (bmod->coeff % c2val == 0 && ramp_min == ramp_max) {
-        return broadcast(floordiv(b1, c2), lanes).Eval();
+      if (ramp_min == ramp_max) {
+        // If b1 can device c2
+        if (bmod->coeff % c2val == 0) {
+          return broadcast(floordiv(b1, c2), lanes).Eval();
+        }
+        // If all indices can be guaranteed to settle inside a coeff range
+        if (c2val % bmod->coeff == 0 && bmod->base + (lanes.Eval() - 1) * 
c1val < bmod->coeff) {

Review comment:
       Please add a unit test in tests_arith_rewrite_simplify to cover this 
rule.




----------------------------------------------------------------
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:
[email protected]


Reply via email to