Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
strongoier committed Dec 20, 2022
1 parent 8bd1f97 commit f191880
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions taichi/analysis/gather_immutable_local_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

namespace taichi::lang {

// The GatherImmutableLocalVars pass gathers all immutable local vars as input
// to the EliminateImmutableLocalVars pass. An immutable local var is an alloca
// which is stored only once (in the same block) and only loaded after that
// store.
class GatherImmutableLocalVars : public BasicStmtVisitor {
private:
using BasicStmtVisitor::visit;
Expand Down
6 changes: 5 additions & 1 deletion taichi/transforms/eliminate_immutable_local_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@

namespace taichi::lang {

// The EliminateImmutableLocalVars pass eliminates all immutable local vars
// calculated from the GatherImmutableLocalVars pass. An immutable local var
// can be eliminated by forwarding the value of its only store to all loads
// after that store. See https://github.com/taichi-dev/taichi/pull/6926 for the
// background of this optimization.
class EliminateImmutableLocalVars : public BasicStmtVisitor {
private:
using BasicStmtVisitor::visit;

DelayedIRModifier modifier_;

std::unordered_set<Stmt *> immutable_local_vars_;
std::unordered_map<Stmt *, Stmt *> immutable_local_var_to_value_;

Expand Down

0 comments on commit f191880

Please sign in to comment.