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


##########
src/arith/analyzer.cc:
##########
@@ -108,29 +108,25 @@ bool Analyzer::CanProveEqual(const PrimExpr& lhs, const 
PrimExpr& rhs) {
 }
 
 bool Analyzer::CanProve(const PrimExpr& expr) {
-  if (const auto* ptr = expr.as<IntImmNode>()) {
-    return ptr->value != 0;
-  }
-  auto res = this->rewrite_simplify(expr);
-  if (const auto* ptr = res.as<IntImmNode>()) {
-    return ptr->value != 0;
-  }
-  res = this->canonical_simplify(expr);
-  if (const auto* ptr = res.as<IntImmNode>()) {
-    return ptr->value != 0;
-  }
-  return false;
+  PrimExpr simplified = Simplify(expr);
+  const int64_t* as_int = tir::as_const_int(simplified);
+  return as_int && *as_int;
 }
 
 PrimExpr Analyzer::Simplify(const PrimExpr& expr, int steps) {
-  if (tir::is_const_int(expr)) return expr;
   PrimExpr res = expr;
-  for (int i = 0; i < steps; ++i) {
-    res = this->rewrite_simplify(res);
-    if (tir::is_const_int(res) || ++i == steps) return res;
-    res = this->canonical_simplify(res);
-    if (tir::is_const_int(res)) return res;
+
+  for (int i = 0; i < steps; i++) {
+    if (tir::is_const_int(res)) {

Review Comment:
   Sounds good and changed.  The break and the early return both result in the 
same optimized assembly in g++, so I initially went with the break because I 
found it easier to read.



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