From 09400f632f04e10a2190f9c9676a37f4b64a7174 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 25 Feb 2023 09:16:32 -0800 Subject: [PATCH] Bounds visitors for min/max were missing single_point mutated case (#7377) * Bounds visitors for min/max were missing single_point mutated case Partially fixes #7374 * Add test --- src/Bounds.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Bounds.cpp b/src/Bounds.cpp index 575e6343aed9..aec4fa5a7bf6 100644 --- a/src/Bounds.cpp +++ b/src/Bounds.cpp @@ -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)); @@ -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)); @@ -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 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; }