Skip to content

Commit 17beccb

Browse files
committed
Added a missing simplification
1 parent e4803cb commit 17beccb

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/arith/rewrite_simplify.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,8 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const FloorDivNode* op) {
907907
TVM_TRY_REWRITE(floordiv(x * c1, x), c1);
908908
TVM_TRY_REWRITE(floordiv(c1 * x, x), c1);
909909

910+
TVM_TRY_REWRITE(floordiv(floormod(x, 2) + 1, 2), floormod(x, 2));
911+
910912
// Rules involving 2-operands.
911913
TVM_TRY_REWRITE_IF(floordiv(min(x * c1, y), c2), min(x * floordiv(c1, c2), floordiv(y, c2)),
912914
c2.Eval()->value > 0 && c1.Eval()->value % c2.Eval()->value == 0);

tests/python/unittest/test_arith_rewrite_simplify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ class TestFloorModTwo(BaseCompare):
584584
TestCase(fld(x, 2) - fld(x - 1, 2), flm(x, 2) * -1 + 1),
585585
TestCase(fld(x + 5, 2) - fld(x - 2, 2), flm(x, 2) + 3),
586586
TestCase(fld(x + 5, 2) - fld(x - 3, 2), 4),
587+
TestCase(fld(flm(x, 2) + 1, 2), flm(x, 2)),
587588
# Sum of floordiv and floormod to yield floordiv
588589
TestCase(fld(x + 1, 2) - flm(x, 2), fld(x, 2)),
589590
TestCase(fld(x, 2) + flm(x, 2), fld(x + 1, 2)),

0 commit comments

Comments
 (0)