Skip to content

Commit f4b74ba

Browse files
authored
Add Check about negative uint constant (#10484)
* fix InferType bug * fix InferType related bug * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative
1 parent 704ac8b commit f4b74ba

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/arith/const_fold.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ inline PrimExpr TryConstFold<tir::Add>(PrimExpr a, PrimExpr b) {
108108
template <>
109109
inline PrimExpr TryConstFold<tir::Sub>(PrimExpr a, PrimExpr b) {
110110
TVM_ARITH_CONST_PROPAGATION({
111+
ICHECK(!(pa && pa->dtype.is_uint() && pa->value == 0U && b.dtype().is_uint()))
112+
<< "Checked failed. Minuend 's value is 0U and it's dtype is uint "
113+
<< "while Subtrahend's dtype is uint; which will cause a negative uint";
111114
const DataType& rtype = a.dtype();
112115
if (pa && pb) return IntImm(rtype, pa->value - pb->value);
113116
if (pb && pb->value == 0) return a;

0 commit comments

Comments
 (0)