Skip to content
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

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Simplify_Stmts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,15 @@ Stmt Simplify::visit(const For *op) {
loop_var_info);

// If we're in the loop, the extent must be greater than 0.
ScopedFact fact = scoped_truth(extent_positive);
ScopedFact fact_extent_positive = scoped_truth(extent_positive);

// 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);
Copy link
Member

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.

Copy link
Contributor Author

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.


ScopedFact fact_loop_var_ge_than_min = scoped_truth(new_min <= loop_var);

new_body = mutate(op->body);
}

Expand Down
Loading