Skip to content

Commit 9c8158d

Browse files
WIP v6: reduce number of redundant continue stmts, few still remain
1 parent 2716dcb commit 9c8158d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/blocks/loops.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ stmt::Ptr loop::convert_to_ast_impl(dominator_analysis &dta_, std::vector<std::p
383383
if (blocks_id_map.count(next_preorder))
384384
is_last_block = false;
385385
else {
386-
if (unique_exit_block && (next_preorder == (int)unique_exit_block->id))
386+
if (!blocks_id_map.count(next_preorder) || !blocks_id_map.count(next_next_preorder))
387+
is_last_block = true;
388+
else if (unique_exit_block && (next_preorder == (int)unique_exit_block->id))
387389
is_last_block = true;
388390
else if (unique_exit_block && (next_next_preorder == (int)unique_exit_block->id))
389391
is_last_block = true;
@@ -397,6 +399,7 @@ stmt::Ptr loop::convert_to_ast_impl(dominator_analysis &dta_, std::vector<std::p
397399
}
398400

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

0 commit comments

Comments
 (0)