Skip to content

Commit

Permalink
loosen preconditions on div by single point in Bounds.cpp (#5407)
Browse files Browse the repository at this point in the history
Loosen preconditions on div by single point for integers
  • Loading branch information
rootjalex committed Oct 28, 2020
1 parent d5e425e commit 3fd654f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,11 @@ class Bounds : public IRVisitor {
} else if (can_prove(b.min == b.max)) {
Expr e1 = a.has_lower_bound() ? a.min / b.min : a.min;
Expr e2 = a.has_upper_bound() ? a.max / b.max : a.max;
if (is_positive_const(b.min) || op->type.is_uint()) {
// TODO: handle real numbers with can_prove(b.min > 0) and can_prove(b.min < 0) as well - treating floating point as
// reals can be error prone when dealing with division near 0, so for now we only consider integers in the can_prove() path
if (op->type.is_uint() || is_positive_const(b.min) || (op->type.is_int() && can_prove(b.min >= 0))) {
interval = Interval(e1, e2);
} else if (is_negative_const(b.min)) {
} else if (is_negative_const(b.min) || (op->type.is_int() && can_prove(b.min <= 0))) {
if (e1.same_as(Interval::neg_inf())) {
e1 = Interval::pos_inf();
}
Expand Down

0 comments on commit 3fd654f

Please sign in to comment.