halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.78k stars 1.07k forks source link

scoped_truth for the loop variable being always less than the loop extent. #8306

Closed mcourteaux closed 1 week ago

mcourteaux commented 1 week ago

Fixes #8303

abadams commented 1 week ago

This is actually a bit more subtle, because it's loop_var < min + extent, not loop_var < extent, but a scoped truth comparison on non-constants will really just look for that exact Expr. Maybe loop_var < mutate(min + extent, nullptr)?

mcourteaux commented 1 week ago

Aren't loops rebased to have a zero starting range at that point?

abadams commented 1 week ago

The simplifier can run on almost any piece of IR, before or after loops get rebased to zero, so if you wanted to go with that strategy you'd have to add an if (is_const_zero(op->min))

EDIT: But if is is zero, then the thing I suggested above will collapse to just the extent anyway.

mcourteaux commented 1 week ago

@abadams Okay, I think I fixed it. Thanks for helping out!