@@ -122,8 +122,14 @@ class IntrinInjecter : public tvm::arith::IRMutatorWithAnalyzer {
122122 return truncdiv (op->a , op->b );
123123 }
124124
125+ // NOTE: Disabled due to integer overflow risk in `a + b * c`.
126+ // The transformation `floordiv(a,b) -> truncdiv(a + b*c, b) - c`
127+ // may overflow when `a` is near type limit and `c` is large,
128+ // producing incorrect results.
129+
125130 // If the numerator's lower bound is known, express the floordiv
126131 // in terms of truncdiv using only positive operands.
132+ /*
127133 arith::ConstIntBound const_int_bound = analyzer_->const_int_bound(op->a);
128134 if (const_int_bound->min_value < 0 &&
129135 const_int_bound->min_value >
@@ -165,6 +171,7 @@ class IntrinInjecter : public tvm::arith::IRMutatorWithAnalyzer {
165171 analyzer_->Simplify(op->a + op->b * ceildiv);
166172 return truncdiv(offset_numerator, op->b) - ceildiv;
167173 }
174+ */
168175
169176 DLOG (INFO) << " LowerFloorDiv: Cannot decide the sign of divident" ;
170177 PrimExpr rdiv = truncdiv (op->a , op->b );
@@ -223,8 +230,14 @@ class IntrinInjecter : public tvm::arith::IRMutatorWithAnalyzer {
223230 return truncmod (op->a , op->b );
224231 }
225232
233+ // NOTE: Disabled due to integer overflow risk in `a + b * c`.
234+ // The transformation `floordiv(a,b) -> truncdiv(a + b*c, b) - c`
235+ // may overflow when `a` is near type limit and `c` is large,
236+ // producing incorrect results.
237+
226238 // If the numerator's lower bound is known, express the floormod
227239 // in terms of truncmod using only positive operands.
240+ /*
228241 arith::ConstIntBound const_int_bound = analyzer_->const_int_bound(op->a);
229242 if (const_int_bound->min_value < 0 &&
230243 const_int_bound->min_value >
@@ -265,6 +278,7 @@ class IntrinInjecter : public tvm::arith::IRMutatorWithAnalyzer {
265278 analyzer_->Simplify(op->a + op->b * ceildiv);
266279 return truncmod(offset_numerator, op->b);
267280 }
281+ */
268282
269283 DLOG (INFO) << " LowerFloorMod: Cannot decide the sign of divident" ;
270284 // NOTE:condition on b >= 0.
0 commit comments