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


##########
src/arith/rewrite_simplify.cc:
##########
@@ -1177,6 +1177,12 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
MinNode* op) {
     TVM_TRY_REWRITE_IF(matches_one_of(min(x, floordiv(x, c2) * c2), 
min(floordiv(x, c2) * c2, x)),
                        floordiv(x, c2) * c2, c2.Eval()->value > 0);
 
+    TVM_TRY_REWRITE_IF(matches_one_of(min(floordiv(x + c1, c2) * c2 + c3, c4),

Review Comment:
   This rewrite rule isn't correct, as it assumes that `x` is non-negative.
   
   The expression `min( (x + 15) // 16 * 16 + 15, 0)` would match this pattern 
with `{c1: 15, c2: 16, c3: 15, c4: 0}`, and would be rewritten to `0`.  
However, if `x` were `-1024`, then this expression should evaluate to 
`min(-1009, 0)`.



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

Reply via email to