From 9f97630d00d463886f4bdbf1dbf629c0a7e7159c Mon Sep 17 00:00:00 2001 From: Sergei Grechanik Date: Wed, 30 Oct 2019 14:42:33 +0300 Subject: [PATCH] [ARITH] Fix the rule y < x && x <= y --- src/arithmetic/rewrite_simplify.cc | 2 +- tests/python/unittest/test_arith_rewrite_simplify.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arithmetic/rewrite_simplify.cc b/src/arithmetic/rewrite_simplify.cc index c55385331655..b26f8335055a 100644 --- a/src/arithmetic/rewrite_simplify.cc +++ b/src/arithmetic/rewrite_simplify.cc @@ -1610,7 +1610,7 @@ Mutate_(const And* op, const Expr& self) { TVM_TRY_REWRITE(x != y && x == y, cfalse); TVM_TRY_REWRITE(x && !x, cfalse); TVM_TRY_REWRITE(x <= y && y < x, cfalse); - TVM_TRY_REWRITE(y < x && y <= x, cfalse); + TVM_TRY_REWRITE(y < x && x <= y, cfalse); TVM_TRY_REWRITE_IF(x < c1 && c2 < x, cfalse, c2.Eval()->value + 1 >= c1.Eval()->value); diff --git a/tests/python/unittest/test_arith_rewrite_simplify.py b/tests/python/unittest/test_arith_rewrite_simplify.py index 246ac1339fb2..99c2942cd470 100644 --- a/tests/python/unittest/test_arith_rewrite_simplify.py +++ b/tests/python/unittest/test_arith_rewrite_simplify.py @@ -783,7 +783,7 @@ def test_logical_simplify(): tvm.const(False, "bool")) ck.verify(tvm.expr.And(x > 1, tvm.expr.Not(x > 1)), tvm.const(False, "bool")) ck.verify(tvm.expr.And(x <= y, y < x), tvm.const(False, "bool")) - ck.verify(tvm.expr.And(y < x, y <= x), tvm.const(False, "bool")) + ck.verify(tvm.expr.And(y < x, x <= y), tvm.const(False, "bool")) ck.verify(tvm.expr.And(x < 1, 0 < x), tvm.const(False, "bool")) ck.verify(tvm.expr.And(x < 0, 1 < x), tvm.const(False, "bool")) ck.verify(tvm.expr.And(x < 1, 1 <= x), tvm.const(False, "bool"))