diff --git a/compiler/circle2circle/src/Circle2Circle.cpp b/compiler/circle2circle/src/Circle2Circle.cpp index 99b10c5fbe2..0965618048e 100644 --- a/compiler/circle2circle/src/Circle2Circle.cpp +++ b/compiler/circle2circle/src/Circle2Circle.cpp @@ -518,7 +518,7 @@ int entry(int argc, char **argv) luci::change_outputs(graph, new_outputs); } - // call luci optimizations for module before optimizations for graph + // call luci optimizations for module optimizer.optimize(module.get()); for (size_t idx = 0; idx < module->size(); ++idx) diff --git a/compiler/luci/pass/src/EliminateDeadSubgraphPass.cpp b/compiler/luci/pass/src/EliminateDeadSubgraphPass.cpp index 03550fda210..5653c1b6e9f 100644 --- a/compiler/luci/pass/src/EliminateDeadSubgraphPass.cpp +++ b/compiler/luci/pass/src/EliminateDeadSubgraphPass.cpp @@ -28,15 +28,15 @@ namespace { // Go through the current graph and check all other graphs reachable from it and save it. -// Note: The main idea for finding achievable graphs is that we can get into other graphs only -// from some operations (see the list below) and we check the graph numbers from these operations. +// Note: The main idea for finding achievable graphs is that we can reach other graphs only +// from some operations (see the list below) and we check the graph indexes from these operations. void checkGraph(loco::Graph *current_graph, std::deque &reachable_graphs_indexes_q) { assert(current_graph != nullptr); // 1 - Obtain all active nodes in current graph // 2 - Go through all active nodes and check its types - // 3 - If it is possible to get to another graph from the operation (see the list below), + // 3 - If it is possible to reach another graph from the current operation (see the list below), // then add the graph numbers to our queue // 1 - Obtain all active nodes in current graph @@ -49,37 +49,34 @@ void checkGraph(loco::Graph *current_graph, std::deque &reachable_graphs // TODO: check all nodes which can be used to reach different subgraph for (auto &node : active_nodes) { - auto *circle_node = dynamic_cast(node); - assert(circle_node != nullptr); + auto *circle_node = loco::must_cast(node); switch (circle_node->opcode()) { case CircleOpcode::WHILE: { - auto *while_node = dynamic_cast(circle_node); - assert(while_node != nullptr); + auto *while_node = loco::must_cast(circle_node); // Get body and cond graph indexes int32_t body_graph_index = while_node->body_branch(); int32_t cond_graph_index = while_node->cond_branch(); assert(body_graph_index >= 0); assert(cond_graph_index >= 0); // Add indexes into queue - reachable_graphs_indexes_q.push_back(size_t(body_graph_index)); - reachable_graphs_indexes_q.push_back(size_t(cond_graph_index)); + reachable_graphs_indexes_q.push_back(static_cast(body_graph_index)); + reachable_graphs_indexes_q.push_back(static_cast(cond_graph_index)); } break; case CircleOpcode::IF: { - auto *if_node = dynamic_cast(circle_node); - assert(if_node != nullptr); + auto *if_node = loco::must_cast(circle_node); // Get then and else graph indexes int32_t else_index = if_node->else_branch(); int32_t then_index = if_node->then_branch(); assert(else_index >= 0); assert(then_index >= 0); // Add indexes into queue - reachable_graphs_indexes_q.push_back(size_t(else_index)); - reachable_graphs_indexes_q.push_back(size_t(then_index)); + reachable_graphs_indexes_q.push_back(static_cast(else_index)); + reachable_graphs_indexes_q.push_back(static_cast(then_index)); } break; default: diff --git a/compiler/luci/pass/src/EliminateDeadSubgraphPass.test.cpp b/compiler/luci/pass/src/EliminateDeadSubgraphPass.test.cpp index d9b6af899e4..950066178e9 100644 --- a/compiler/luci/pass/src/EliminateDeadSubgraphPass.test.cpp +++ b/compiler/luci/pass/src/EliminateDeadSubgraphPass.test.cpp @@ -129,5 +129,5 @@ TEST_F(EliminateDeadSubgraphPassTest, no_graphs_NEG) { luci::EliminateDeadSubgraphPass pass; auto m = luci::make_module(); - ASSERT_ANY_THROW(pass.run(m.get())); + ASSERT_FALSE(pass.run(m.get())); }