From: Sergei Grechanik Date: Tue, 4 Jun 2019 15:42:27 +0000 (+0300) Subject: [ARITH] Bugfix: int bound analysis for mod (#3288) X-Git-Tag: upstream/0.7.0~2362 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a81086684d7aeed57c2fd777e3c2f03c8bd3273;p=platform%2Fupstream%2Ftvm.git [ARITH] Bugfix: int bound analysis for mod (#3288) --- diff --git a/src/arithmetic/const_int_bound.cc b/src/arithmetic/const_int_bound.cc index 72b8508..ed8faba 100644 --- a/src/arithmetic/const_int_bound.cc +++ b/src/arithmetic/const_int_bound.cc @@ -190,7 +190,7 @@ class ConstIntBoundAnalyzer::Impl : std::min(a.max_value, b_max_cap)); } else { return MakeBound(std::max(a.min_value, -b_max_cap), - std::min(a.max_value, b_max_cap)); + std::min(std::max(a.max_value, (int64_t)0), b_max_cap)); } } else { CHECK(!b.is_const(0)) << "mod by zero"; diff --git a/tests/python/unittest/test_arith_rewrite_simplify.py b/tests/python/unittest/test_arith_rewrite_simplify.py index ee113e1..596e54d 100644 --- a/tests/python/unittest/test_arith_rewrite_simplify.py +++ b/tests/python/unittest/test_arith_rewrite_simplify.py @@ -564,6 +564,7 @@ def test_cmp_simplify(): ck.verify((x + 1)*(y - 1) < 0, tvm.const(1, "bool")) ck.verify(y*y >= 0, tvm.const(1, "bool")) ck.verify(x*6 <= -3, tvm.const(0, "bool")) + ck.verify((y - 1) % 3 == 0, (y + (-1)) % 3 == 0) def test_logical_simplify():