Skip to content

Commit

Permalink
Bounds visitors for min/max were missing single_point mutated case (#…
Browse files Browse the repository at this point in the history
…7377)

* Bounds visitors for min/max were missing single_point mutated case

Partially fixes #7374

* Add test
  • Loading branch information
abadams committed Feb 25, 2023
1 parent b6a18b8 commit 09400f6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ class Bounds : public IRVisitor {

if (a.is_single_point(op->a) && b.is_single_point(op->b)) {
interval = Interval::single_point(op);
} else if (a.is_single_point() && b.is_single_point()) {
interval = Interval::single_point(Interval::make_min(a.min, b.min));
} else {
interval = Interval(Interval::make_min(a.min, b.min),
Interval::make_min(a.max, b.max));
Expand All @@ -763,6 +765,8 @@ class Bounds : public IRVisitor {

if (a.is_single_point(op->a) && b.is_single_point(op->b)) {
interval = Interval::single_point(op);
} else if (a.is_single_point() && b.is_single_point()) {
interval = Interval::single_point(Interval::make_max(a.min, b.min));
} else {
interval = Interval(Interval::make_max(a.min, b.min),
Interval::make_max(a.max, b.max));
Expand Down Expand Up @@ -3707,6 +3711,17 @@ void bounds_test() {
check_constant_bound(e4, u16(0), u16(65535));
}

// Test case from https://github.com/halide/Halide/pull/7377
{
Var x;
Expr e = Load::make(Int(32), "buf", max(x, -x), Buffer<>{}, Parameter{}, const_true(), ModulusRemainder{});
e = Let::make(x.name(), 37, e);
Scope<Interval> scope;
scope.push("y", {0, 100});
Interval in = bounds_of_expr_in_scope(e, scope);
internal_assert(in.is_single_point());
}

std::cout << "Bounds test passed" << std::endl;
}

Expand Down

0 comments on commit 09400f6

Please sign in to comment.