Skip to content

Commit

Permalink
Restore control_flow_graph.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
squarefk committed Nov 1, 2021
1 parent cceb9ae commit 2345ee0
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions taichi/ir/control_flow_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ Stmt *CFGNode::get_store_forwarding_data(Stmt *var, int position) const {
}
}
if (!result) {
// Don't analyze PtrOffsetStmt for now.
if (var->is<PtrOffsetStmt>())
return nullptr;

// The UD-chain is empty.
TI_WARN("stmt {} loaded in stmt {} before storing.", var->id,
block->statements[position]->id);
Expand Down Expand Up @@ -413,7 +409,6 @@ void CFGNode::live_variable_analysis(bool after_lower_access) {
}
}

// TODO: Rename this which deals with both dead store and identical load
bool CFGNode::dead_store_elimination(bool after_lower_access) {
bool modified = false;
std::unordered_set<Stmt *> live_in_this_node;
Expand All @@ -437,9 +432,8 @@ bool CFGNode::dead_store_elimination(bool after_lower_access) {
if (store_ptrs.size() == 1) {
// Dead store elimination
auto store_ptr = store_ptrs.front();
if ((!after_lower_access || (store_ptr->is<AllocaStmt>() ||
store_ptr->is<AdStackAllocaStmt>())) &&
!store_ptr->is<PtrOffsetStmt>()) {
if (!after_lower_access ||
(store_ptr->is<AllocaStmt>() || store_ptr->is<AdStackAllocaStmt>())) {
// After lower_access, we only analyze local variables and stacks.
// Do not eliminate AllocaStmt and AdStackAllocaStmt here.
if (!stmt->is<AllocaStmt>() && !stmt->is<AdStackAllocaStmt>() &&
Expand Down Expand Up @@ -503,9 +497,8 @@ bool CFGNode::dead_store_elimination(bool after_lower_access) {
if (load_ptrs.size() == 1 && store_ptrs.empty() && stmt->width() == 1) {
// Identical load elimination
auto load_ptr = load_ptrs.front();
if ((!after_lower_access ||
(load_ptr->is<AllocaStmt>() || load_ptr->is<AdStackAllocaStmt>())) &&
!load_ptr->is<PtrOffsetStmt>()) {
if (!after_lower_access ||
(load_ptr->is<AllocaStmt>() || load_ptr->is<AdStackAllocaStmt>())) {
// After lower_access, we only analyze local variables and stacks.
if (live_load_in_this_node.find(load_ptr) !=
live_load_in_this_node.end() &&
Expand Down

0 comments on commit 2345ee0

Please sign in to comment.