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

Reduce redundant analysis in pass/shrink_for #588

Merged
merged 1 commit into from
Jan 17, 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
25 changes: 12 additions & 13 deletions src/pass/shrink_for.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Stmt ShrinkFor::visitStmt(const Stmt &stmt) {
default:;
}
if (checker.hasSideEffect()) {
for (auto &&[_var, _names] : views::zip(iterStack_, namesStack_)) {
for (auto &&[var, _names] : views::zip(iterStack_, namesStack_)) {
auto &&names = filterNames(_names);

// We need linear programming from PBCompBounds, because the
Expand All @@ -239,8 +239,6 @@ Stmt ShrinkFor::visitStmt(const Stmt &stmt) {
// PBCompBounds requires one instance per Stmt
CompUniqueBoundsPBWithStride bound(*this);

// Trigger recomputing in analyze/comp_unique_bounds
auto var = deepCopy(_var).as<VarNode>();
newRange_[var].emplace_back(
bound.getBound(var)->restrictScope(names));
}
Expand All @@ -253,16 +251,17 @@ Stmt ShrinkFor::visit(const For &_op) {
auto var = makeVar(_op->iter_).as<VarNode>();
newRange_.erase(var);

iterStack_.emplace_back(var);
namesStack_.emplace_back(names());
auto __op = BaseClass::visit(_op);
ASSERT(__op->nodeType() == ASTNodeType::For);
auto op = __op.as<ForNode>();
namesStack_.pop_back();
iterStack_.pop_back();

if ((subAST_.isValid() && !inSubAST_) || !filterLoop(op)) {
return op;
For op;
if ((subAST_.isValid() && !inSubAST_) || !filterLoop(_op)) {
return BaseClass::visit(_op);
} else {
iterStack_.emplace_back(var);
namesStack_.emplace_back(names());
auto __op = BaseClass::visit(_op);
ASSERT(__op->nodeType() == ASTNodeType::For);
op = __op.as<ForNode>();
namesStack_.pop_back();
iterStack_.pop_back();
}

if (!newRange_.count(var)) {
Expand Down
Loading