Skip to content

Commit

Permalink
[skip ci][Bugfix] Allow constant folding of 0U - 0U (apache#10535)
Browse files Browse the repository at this point in the history
A check for unsigned integer overflow would throw an error if it
encountered 0U - 0U.

apache#10484, which introduced the check,
and apache#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.
  • Loading branch information
Lunderberg authored and pfk-beta committed Apr 11, 2022
1 parent 68f7f68 commit 01ca4db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/arith/const_fold.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ inline PrimExpr TryConstFold<tir::Add>(PrimExpr a, PrimExpr b) {
template <>
inline PrimExpr TryConstFold<tir::Sub>(PrimExpr a, PrimExpr b) {
TVM_ARITH_CONST_PROPAGATION({
ICHECK(!(pa && pa->dtype.is_uint() && pa->value == 0U && b.dtype().is_uint()))
ICHECK(!((pa && pa->dtype.is_uint() && pa->value == 0U) &&
(pb && pb->dtype.is_uint() && pb->value > 0U)))
<< "Checked failed. Minuend 's value is 0U and it's dtype is uint "
<< "while Subtrahend's dtype is uint; which will cause a negative uint";
const DataType& rtype = a.dtype();
Expand Down

0 comments on commit 01ca4db

Please sign in to comment.