-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scoped_truth for the loop variable being always less than the loop extent. #8306
scoped_truth for the loop variable being always less than the loop extent. #8306
Conversation
6fa904b
to
c0c4f73
Compare
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 |
Aren't loops rebased to have a zero starting range at that point? |
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 EDIT: But if is is zero, then the thing I suggested above will collapse to just the extent anyway. |
@abadams Okay, I think I fixed it. Thanks for helping out! |
// The loop variable will never exceed the loop bound. | ||
Expr loop_var = Variable::make(Int(32), op->name); | ||
Expr new_max = mutate(new_min + new_extent, nullptr); | ||
ScopedFact fact_loop_var_less_than_extent = scoped_truth(loop_var < new_max); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding scoped_truth(new_min <= loop_var) while you're here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. My brain is clearly not thinking this through... I committed that as well now.
Fixes #8303