Skip to content

Commit

Permalink
WIP v6: reduce number of redundant continue stmts, few still remain
Browse files Browse the repository at this point in the history
  • Loading branch information
VedantParanjape committed Sep 28, 2023
1 parent 2716dcb commit 9c8158d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/blocks/loops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ stmt::Ptr loop::convert_to_ast_impl(dominator_analysis &dta_, std::vector<std::p
if (blocks_id_map.count(next_preorder))
is_last_block = false;
else {
if (unique_exit_block && (next_preorder == (int)unique_exit_block->id))
if (!blocks_id_map.count(next_preorder) || !blocks_id_map.count(next_next_preorder))
is_last_block = true;
else if (unique_exit_block && (next_preorder == (int)unique_exit_block->id))
is_last_block = true;
else if (unique_exit_block && (next_next_preorder == (int)unique_exit_block->id))
is_last_block = true;
Expand All @@ -397,6 +399,7 @@ stmt::Ptr loop::convert_to_ast_impl(dominator_analysis &dta_, std::vector<std::p
}

if (!is_last_block) {
std::cerr << "inserted continue: " << bb->id << loop_id << "\n";
ast->stmts.push_back(to<stmt>(std::make_shared<continue_stmt>()));
while_block->continue_blocks.push_back(ast);
}
Expand Down

0 comments on commit 9c8158d

Please sign in to comment.