Skip to content
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: 25 additions & 0 deletions src/transform/loop_vectorize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,31 @@ class VectorizePlanner : public arith::IRMutatorWithAnalyzer {
}
}

// NOTE(wt): The base class IRMutatorWithAnalyzer::VisitStmt_(LetStmtNode*)
// binds let variables, but this causes issues when the same variable name
// appears multiple times with different values (e.g., in pipelined loops
// where the body is duplicated). For this case, we allow the analyzer to
// override the binding. Check the impl of
// IRMutatorWithAnalyzer::VisitStmt_(LetStmtNode*) in:
// tvm/src/arith/ir_mutator_with_analyzer.cc
Stmt VisitStmt_(const LetStmtNode *op) final {
PrimExpr value = this->VisitExpr(op->value);
if (SideEffect(value) <= CallEffectKind::kPure) {
// Allow override to handle duplicated loop bodies in pipelined loops
analyzer_->Bind(op->var, value, /*allow_override=*/true);
}
// Continue visiting the body to collect vectorization info
Stmt body = this->VisitStmt(op->body);
if (value.same_as(op->value) && body.same_as(op->body)) {
return ffi::GetRef<Stmt>(op);
} else {
auto n = this->CopyOnWrite(op);
n->value = std::move(value);
n->body = std::move(body);
return Stmt(n);
}
}

int vector_load_bits_max_;

const ForNode *inner_for_{};
Expand Down
Loading