Skip to content

Commit

Permalink
[ARITH] Fix x||!x for comparisons in rewrite simplifier (apache#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrechanik-h authored and Wei Chen committed May 13, 2019
1 parent 1db51e3 commit 1d71097
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/arithmetic/rewrite_simplify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ Mutate_(const Or* op, const Expr& self) {
TVM_TRY_REWRITE(x != y || x == y, ctrue);
TVM_TRY_REWRITE(x || !x, ctrue);
TVM_TRY_REWRITE(x <= y || y < x, ctrue);
TVM_TRY_REWRITE(y < x || y <= x, ctrue);
TVM_TRY_REWRITE(y < x || x <= y, ctrue);

TVM_TRY_REWRITE_IF(x < c1 || c2 < x, ctrue,
c2.Eval()->value < c1.Eval()->value);
Expand Down
4 changes: 2 additions & 2 deletions tests/python/unittest/test_arith_rewrite_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ def test_logical_simplify():
tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(tvm.expr.NE(x, y), tvm.expr.EQ(x, y)),
tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(x > y, tvm.expr.Not(x < y)), tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(x > y, tvm.expr.Not(x > y)), tvm.const(True, "bool"))

ck.verify(tvm.expr.Or(x <= y, y < x), tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(y < x, y <= x), tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(y < x, y >= x), tvm.const(True, "bool"))

ck.verify(tvm.expr.Or(x < 1, 0 < x), tvm.const(True, "bool"))
ck.verify(tvm.expr.Or(0 < x, x < 1), tvm.const(True, "bool"))
Expand Down

0 comments on commit 1d71097

Please sign in to comment.