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

Simplify before substitution to avoid huge expressions #578

Merged
merged 1 commit into from
Jan 30, 2025
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
15 changes: 8 additions & 7 deletions builder/slide_and_fold_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,15 @@ class slide_and_fold : public stmt_mutator {
if (bounds) {
define_undef_bounds(*bounds, op->sym);
substitute_bounds(*bounds, current_buffer_bounds());
// Now do the reverse substitution, because the updated bounds can be used in other
// bounds.
substitute_bounds(current_buffer_bounds(), op->sym, *bounds);

// This simplify can be heavy, but is really useful in reducing the size of the
// expressions.
for (auto& b : *bounds) {
b = simplify(b);
}

// Now do the reverse substitution, because the updated bounds can be used in other
// bounds.
substitute_bounds(current_buffer_bounds(), op->sym, *bounds);
}

auto set_bounds = set_value_in_scope(current_buffer_bounds(), op->sym, bounds);
Expand All @@ -545,15 +545,16 @@ class slide_and_fold : public stmt_mutator {
merge_crop(bounds, op->dim, op->bounds);
define_undef_bounds(*bounds, op->sym);
substitute_bounds(*bounds, current_buffer_bounds());
// Now do the reverse substitution, because the updated bounds can be used in other
// bounds.
substitute_bounds(current_buffer_bounds(), op->sym, *bounds);
// This simplify can be heavy, but is really useful in reducing the size of the
// expressions.
for (auto& b : *bounds) {
b = simplify(b);
}

// Now do the reverse substitution, because the updated bounds can be used in other
// bounds.
substitute_bounds(current_buffer_bounds(), op->sym, *bounds);

auto set_bounds = set_value_in_scope(current_buffer_bounds(), op->sym, bounds);
auto set_alias = set_value_in_scope(aliases, op->sym, op->src);

Expand Down
Loading