Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-hitonami committed Sep 19, 2022
1 parent 64450a6 commit 7773702
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion taichi/transforms/cache_loop_invariant_global_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class CacheLoopInvariantGlobalVars : public LoopInvariantDetector {

while (true) {
CacheLoopInvariantGlobalVars eliminator(config);
irpass::print(node);
node->accept(&eliminator);
if (eliminator.modifier.modify_ir())
modified = true;
Expand Down
20 changes: 20 additions & 0 deletions taichi/transforms/loop_invariant_code_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ class LoopInvariantCodeMotion : public LoopInvariantDetector {
}
}

void visit(ExternalPtrStmt *stmt) override {
if (is_loop_invariant(stmt, stmt->parent)) {
auto replacement = stmt->clone();
stmt->replace_usages_with(replacement.get());

modifier.insert_before(current_loop_stmt(), std::move(replacement));
modifier.erase(stmt);
}
}

void visit(ArgLoadStmt *stmt) override {
if (is_loop_invariant(stmt, stmt->parent)) {
auto replacement = stmt->clone();
stmt->replace_usages_with(replacement.get());

modifier.insert_before(current_loop_stmt(), std::move(replacement));
modifier.erase(stmt);
}
}

static bool run(IRNode *node, const CompileConfig &config) {
bool modified = false;

Expand Down

0 comments on commit 7773702

Please sign in to comment.