jcf94 commented on a change in pull request #5883:
URL: https://github.com/apache/incubator-tvm/pull/5883#discussion_r443644171
##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -864,6 +902,31 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const
FloorModNode* op) {
TVM_TRY_REWRITE_IF(floormod(x + y * c1, c2), floormod(x, c2),
c2.Eval()->value > 0 && c1.Eval()->value %
c2.Eval()->value == 0);
+ TVM_TRY_REWRITE_IF(floormod(x * c1 + y, c2), floormod(x, floordiv(c2, c1))
* c1 + y,
+ c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+ c2.Eval()->value % c1.Eval()->value == 0 &&
+ CanProveGreaterEqual(-y.Eval(), -c1.Eval()->value + 1));
+
+ // TODO(jcf94): For the next three rules, better use the max common factor
+ // of c1, c2, c3 to do the simplify
+ TVM_TRY_REWRITE_IF(floormod(x * c1 + y * c2 + z, c3),
+ floormod(x * floordiv(c1, c2) + y, floordiv(c3, c2)) *
c2 + z,
+ c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+ c3.Eval()->value > 0 &&
+ c3.Eval()->value % c2.Eval()->value == 0 &&
+ c1.Eval()->value % c2.Eval()->value == 0 &&
+ CanProveGreaterEqual(-z.Eval(), -c2.Eval()->value + 1));
+
+ TVM_TRY_REWRITE_IF(floormod(w * c1 + x * c2 + y * c3 + z, c4),
+ floormod(w * floordiv(c1, c3) + x * floordiv(c2, c3) +
y,
+ floordiv(c4, c3)) * c3 + z,
+ c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+ c3.Eval()->value > 0 && c4.Eval()->value > 0 &&
Review comment:
This is to fix the simplify error in some vectorized cooperative
fetching cases, I'll provide example but not sure whether it's convenient to
write unit test for this ...... Ok, I think it should be fine to check if the
AST can successfully generate ramp node.
----------------------------------------------------------------
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]