@@ -750,6 +750,23 @@ class TestComparisons(BaseCompare):
750750 TestCase ((x - 10 ).equal (0 ), x .equal (10 )),
751751 TestCase ((10 - x ).equal (0 ), x .equal (10 )),
752752 TestCase ((x * y ).equal (0 ), tvm .tir .Or (x .equal (0 ), y .equal (0 ))),
753+ # Write LT as LE for integer arguments, if possible
754+ TestCase (x - 1 < y , x <= y ),
755+ TestCase (x + (- 1 ) < y , x <= y ),
756+ TestCase (x < y - (- 1 ), x <= y ),
757+ TestCase (x < y + 1 , x <= y ),
758+ TestCase (x + 2 < y + 3 , x <= y ),
759+ TestCase (x - 3 < y - 2 , x <= y ),
760+ TestCase (x - 3 < y + (- 2 ), x <= y ),
761+ TestCase (x + (- 3 ) < y - 2 , x <= y ),
762+ # Merge constants on the LHS/RHS of a LT expression.
763+ TestCase (x + 10 < y + 10 , x < y ),
764+ TestCase (x + 5 < y + 10 , x < y + 5 ),
765+ TestCase (x + 10 < y + 5 , x + 5 < y ),
766+ TestCase (x - 5 < y - 10 , x + 5 < y ),
767+ TestCase (x - 10 < y - 5 , x < y + 5 ),
768+ TestCase (x < y - 10 , x + 10 < y ),
769+ TestCase (x - 10 < y , x < y + 10 ),
753770 # cmp bound
754771 TestCase (x + y < x + z , y < z ),
755772 TestCase (x + y < z + x , y < z ),
@@ -815,7 +832,7 @@ class TestComparisons(BaseCompare):
815832 TestCase (tdiv (x , 4 ) * 4 < x - y , tvm .tir .LT (y , tmod (x , 4 ))),
816833 TestCase (tdiv (x + 2 , 4 ) * 4 >= x , tvm .tir .LE (tmod (x + 2 , 4 ), 2 )),
817834 TestCase (tdiv (x + 2 , 4 ) * 4 >= x + y , tvm .tir .LE (tmod (x + 2 , 4 ) + y , 2 )),
818- TestCase (tdiv (x + 2 , 4 ) * 4 >= x - y , tvm .tir .LE (tmod (x + 2 , 4 ) + ( - 2 ), y )),
835+ TestCase (tdiv (x + 2 , 4 ) * 4 >= x - y , tvm .tir .LE (tmod (x + 2 , 4 ), y + 2 )),
819836 # floor div
820837 TestCase (fld (x , 2 ) < 3 , x < 6 ),
821838 TestCase (3 < fld (x , 2 ), tvm .tir .LT (7 , x )),
@@ -833,7 +850,7 @@ class TestComparisons(BaseCompare):
833850 TestCase (fld (x , 4 ) * 4 < x - y , tvm .tir .LT (y , flm (x , 4 ))),
834851 TestCase (fld (x + 2 , 4 ) * 4 >= x , tvm .tir .LE (flm (x + 2 , 4 ), 2 )),
835852 TestCase (fld (x + 2 , 4 ) * 4 >= x + y , tvm .tir .LE (flm (x + 2 , 4 ) + y , 2 )),
836- TestCase (fld (x + 2 , 4 ) * 4 >= x - y , tvm .tir .LE (flm (x + 2 , 4 ) + ( - 2 ), y )),
853+ TestCase (fld (x + 2 , 4 ) * 4 >= x - y , tvm .tir .LE (flm (x + 2 , 4 ), y + 2 )),
837854 # End DivMod Rules
838855 # merging flm/fld into known value
839856 TestCase (tir .all (fld (x , 8 ) == 3 , flm (x , 8 ) == 4 ), x == 28 ),
0 commit comments