Skip to content

Commit d00ea62

Browse files
committed
[Bugfix] Allow constant folding of 0U - 0U
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. #10484, which introduced the check, and #9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
1 parent 7688db7 commit d00ea62

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/arith/const_fold.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ 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()))
111+
ICHECK(!((pa && pa->dtype.is_uint() && pa->value == 0U) &&
112+
(pb && pb->dtype.is_uint() && pb->value > 0U)))
112113
<< "Checked failed. Minuend 's value is 0U and it's dtype is uint "
113114
<< "while Subtrahend's dtype is uint; which will cause a negative uint";
114115
const DataType& rtype = a.dtype();

0 commit comments

Comments
 (0)