Lunderberg commented on code in PR #11373:
URL: https://github.com/apache/tvm/pull/11373#discussion_r880556275
##########
src/arith/rewrite_simplify.cc:
##########
@@ -256,13 +256,16 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const
SubNode* op) {
TVM_TRY_REWRITE(broadcast(x, lanes) - broadcast(y, lanes), broadcast(x -
y, lanes));
}
+ // cancelation rules
+ TVM_TRY_REWRITE_IF(x - x, ZeroWithTypeLike(x),
+ SideEffect(x.Eval()) <= CallEffectKind::kReadState);
+ TVM_TRY_REWRITE_IF((x + y) - y, x, SideEffect(y.Eval()) <=
CallEffectKind::kReadState);
+ TVM_TRY_REWRITE_IF((x + y) - x, y, SideEffect(x.Eval()) <=
CallEffectKind::kReadState);
+ TVM_TRY_REWRITE_IF(x - (y + x), 0 - y, SideEffect(x.Eval()) <=
CallEffectKind::kReadState);
+ TVM_TRY_REWRITE_IF(x - (x + y), 0 - y, SideEffect(x.Eval()) <=
CallEffectKind::kReadState);
+
if (IsIndexType(op->dtype)) {
// Index rules
- // cancelation rules
Review Comment:
Sounds reasonable, and updated as requested.
--
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]