Anndrey24 commented on code in PR #17046:
URL: https://github.com/apache/tvm/pull/17046#discussion_r1620763529
##########
src/arith/rewrite_simplify.cc:
##########
@@ -1136,8 +1136,15 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const
FloorDivNode* op) {
x + floordiv(y, z), CanProveGreaterEqual(z.Eval(), 0));
TVM_TRY_REWRITE_IF(matches_one_of(floordiv(y + x * z, z), floordiv(y + z *
x, z)),
floordiv(y, z) + x, CanProveGreaterEqual(z.Eval(), 0));
+ TVM_TRY_REWRITE_IF(floordiv(x * z * c1 + y, z * c1), x + floordiv(y, z *
c1),
+ CanProveGreaterEqual(z.Eval() * c1.Eval(), 0));
TVM_TRY_REWRITE_IF(floordiv(x - floormod(x, c1), c1), floordiv(x, c1),
c1.Eval()->value != 0);
+
+ // Scalable divisor
+ TVM_TRY_REWRITE_IF(floordiv(x, y), ZeroWithTypeLike(x),
+ ContainsVscaleCall(y.Eval()) &&
CanProveGreaterEqual(x.Eval(), 0) &&
+ CanProveGreaterEqual(y.Eval(), 0) &&
CanProve(x.Eval() < y.Eval()));
Review Comment:
Oh right, I didn't consider that `x >= 0` and `x < y` would already
necessitate that `y >= 0`. I wouldn't mind removing it, but even apart from
helping with readability like you mentioned, it might save the analyzer calling
the `CanProve()` function when `y < 0` could be proven with a quick
`const_int_bound` check in `CanProveGreaterEqual()`, although it would just be
redundant in the `y >= 0` case.
I'm alright either way too, to be honest.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]