Skip to content

[ARITH]const_int_bound doesn't allow INT64_MAX in expr #6913

@lixiaoquan

Description

@lixiaoquan

Patch to reproduce:

diff --git a/tests/python/unittest/test_arith_const_int_bound.py b/tests/python/unittest/test_arith_const_int_bound.py
index 84fc7fd64..0bcdff487 100644
--- a/tests/python/unittest/test_arith_const_int_bound.py
+++ b/tests/python/unittest/test_arith_const_int_bound.py
@@ -50,6 +50,15 @@ def test_cast_bound():
     assert bd.max_value == 2
 
 
+def test_bound():
+    import numpy as np
+    analyzer = tvm.arith.Analyzer()
+    x, y = te.var("x", "int64"), tvm.tir.const(-np.iinfo(np.int64).max, dtype="int64")
+    bd = analyzer.const_int_bound(x + y)
+    assert bd.min_value == bd.NEG_INF
+    assert bd.max_value == bd.POS_INF
+
+
 def test_add_sub_bound():
     analyzer = tvm.arith.Analyzer()
     x, y = te.var("x", "int64"), te.var("y", "int64")

Because the expr is (x + (int64)-9223372036854775807), it runs into this ICHECK

E             File "/home/xiaoquan.li/tvm/src/arith/const_int_bound.cc", line 455
E           TVMError: 
E           ---------------------------------------------------------------
E           An internal invariant was violated during the execution of TVM.
E           Please read TVM's error reporting guidelines.
E           More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
E           ---------------------------------------------------------------
E             Check failed: y != kNegInf == false:

Since -INT64_MAX is used as kNegInf in const_int_bound, does it mean this value shouldn't be used in TIR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions