summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-manip.c
diff options
context:
space:
mode:
authorhagog <hagog@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-03 08:44:33 +0000
committerhagog <hagog@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-03 08:44:33 +0000
commitc50ae675d1e02325c13da64e4841cb8774b2bb54 (patch)
tree0b472172f6a31148aad4e01247e8d9a83810ecd0 /gcc/tree-ssa-loop-manip.c
parentdf855acf8329407f5ff54914616e381f70e6c962 (diff)
downloadgcc-c50ae675d1e02325c13da64e4841cb8774b2bb54.tar.gz
2005-03-30 Mostafa Hagog <mustafa@il.ibm.com>
* cfghooks.c (lv_flush_pending_stmts, cfg_hook_duplicate_loop_to_header_edge, extract_cond_bb_edges, lv_adjust_loop_header_phi, lv_add_condition_to_bb): New. * cfghooks.h (cfg_hook_duplicate_loop_to_header_edge, lv_add_condition_to_bb, lv_adjust_loop_header_phi, extract_cond_bb_edges, flush_pending_stmts): New in cfg_hooks structure. (cfg_hook_duplicate_loop_to_header_edge, lv_flush_pending_stmts, extract_cond_bb_edges, lv_adjust_loop_header_phi, lv_add_condition_to_bb): New declarations. * cfgloop.h (duplicate_loop_to_header_edge): Change return type to bool. (loop_version): Declare. * cfgloopmanip.c (cfghooks.h): Include. (duplicate_loop_to_header_edge): Change return type to bool. (loop_version, lv_adjust_loop_entry_edge): Move here. * cfgrtl.c (cfgloop.h): Include. (rtl_verify_flow_info_1): Fix. (rtl_lv_add_condition_to_bb, rtl_extract_cond_bb_edges): New. (rtl_cfg_hooks, cfg_layout_rtl_cfg_hook): Add hooks to initialization. * tree-cfg.c (tree_lv_adjust_loop_header_phi, tree_lv_add_condition_to_bb): New. (tree_cfg_hooks): Add new hooks to initialization. * tree-ssa-loop-manip.c (lv_adjust_loop_header_phi, lv_adjust_loop_entry_edge, tree_ssa_loop_version): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97481 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-manip.c')
-rw-r--r--gcc/tree-ssa-loop-manip.c176
1 files changed, 0 insertions, 176 deletions
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 71d34614816..1bb4c4c3aa1 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -677,179 +677,3 @@ tree_duplicate_loop_to_header_edge (struct loop *loop, edge e,
return true;
}
-/*---------------------------------------------------------------------------
- Loop versioning
- ---------------------------------------------------------------------------*/
-
-/* Adjust phi nodes for 'first' basic block. 'second' basic block is a copy
- of 'first'. Both of them are dominated by 'new_head' basic block. When
- 'new_head' was created by 'second's incoming edge it received phi arguments
- on the edge by split_edge(). Later, additional edge 'e' was created to
- connect 'new_head' and 'first'. Now this routine adds phi args on this
- additional edge 'e' that new_head to second edge received as part of edge
- splitting.
-*/
-
-static void
-lv_adjust_loop_header_phi (basic_block first, basic_block second,
- basic_block new_head, edge e)
-{
- tree phi1, phi2;
-
- /* Browse all 'second' basic block phi nodes and add phi args to
- edge 'e' for 'first' head. PHI args are always in correct order. */
-
- for (phi2 = phi_nodes (second), phi1 = phi_nodes (first);
- phi2 && phi1;
- phi2 = PHI_CHAIN (phi2), phi1 = PHI_CHAIN (phi1))
- {
- edge e2 = find_edge (new_head, second);
-
- if (e2)
- {
- tree def = PHI_ARG_DEF (phi2, e2->dest_idx);
- add_phi_arg (phi1, def, e);
- }
- }
-}
-
-/* Adjust entry edge for lv.
-
- e is an incoming edge.
-
- --- edge e ---- > [second_head]
-
- Split it and insert new conditional expression and adjust edges.
-
- --- edge e ---> [cond expr] ---> [first_head]
- |
- +---------> [second_head]
-
-*/
-
-static basic_block
-lv_adjust_loop_entry_edge (basic_block first_head,
- basic_block second_head,
- edge e,
- tree cond_expr)
-{
- block_stmt_iterator bsi;
- basic_block new_head = NULL;
- tree goto1 = NULL_TREE;
- tree goto2 = NULL_TREE;
- tree new_cond_expr = NULL_TREE;
- edge e0, e1;
-
- gcc_assert (e->dest == second_head);
-
- /* Split edge 'e'. This will create a new basic block, where we can
- insert conditional expr. */
- new_head = split_edge (e);
-
- /* Build new conditional expr */
- goto1 = build1 (GOTO_EXPR, void_type_node, tree_block_label (first_head));
- goto2 = build1 (GOTO_EXPR, void_type_node, tree_block_label (second_head));
- new_cond_expr = build3 (COND_EXPR, void_type_node, cond_expr, goto1, goto2);
-
- /* Add new cond. in new head. */
- bsi = bsi_start (new_head);
- bsi_insert_after (&bsi, new_cond_expr, BSI_NEW_STMT);
-
- /* Adjust edges appropriately to connect new head with first head
- as well as second head. */
- e0 = single_succ_edge (new_head);
- e0->flags &= ~EDGE_FALLTHRU;
- e0->flags |= EDGE_FALSE_VALUE;
- e1 = make_edge (new_head, first_head, EDGE_TRUE_VALUE);
- set_immediate_dominator (CDI_DOMINATORS, first_head, new_head);
- set_immediate_dominator (CDI_DOMINATORS, second_head, new_head);
-
- /* Adjust loop header phi nodes. */
- lv_adjust_loop_header_phi (first_head, second_head, new_head, e1);
-
- return new_head;
-}
-
-/* Main entry point for Loop Versioning transformation.
-
-This transformation given a condition and a loop, creates
--if (condition) { loop_copy1 } else { loop_copy2 },
-where loop_copy1 is the loop transformed in one way, and loop_copy2
-is the loop transformed in another way (or unchanged). 'condition'
-may be a run time test for things that were not resolved by static
-analysis (overlapping ranges (anti-aliasing), alignment, etc.). */
-
-struct loop *
-tree_ssa_loop_version (struct loops *loops, struct loop * loop,
- tree cond_expr, basic_block *condition_bb)
-{
- edge entry, latch_edge, exit, true_edge, false_edge;
- basic_block first_head, second_head;
- int irred_flag;
- struct loop *nloop;
-
- /* CHECKME: Loop versioning does not handle nested loop at this point. */
- if (loop->inner)
- return NULL;
-
- /* Record entry and latch edges for the loop */
- entry = loop_preheader_edge (loop);
-
- /* Note down head of loop as first_head. */
- first_head = entry->dest;
-
- /* Duplicate loop. */
- irred_flag = entry->flags & EDGE_IRREDUCIBLE_LOOP;
- entry->flags &= ~EDGE_IRREDUCIBLE_LOOP;
- if (!tree_duplicate_loop_to_header_edge (loop, entry, loops, 1,
- NULL, NULL, NULL, NULL, 0))
- {
- entry->flags |= irred_flag;
- return NULL;
- }
-
- /* After duplication entry edge now points to new loop head block.
- Note down new head as second_head. */
- second_head = entry->dest;
-
- /* Split loop entry edge and insert new block with cond expr. */
- *condition_bb = lv_adjust_loop_entry_edge (first_head, second_head, entry,
- cond_expr);
-
- latch_edge = single_succ_edge (loop->latch->rbi->copy);
-
- extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
- nloop = loopify (loops,
- latch_edge,
- single_pred_edge (loop->header->rbi->copy),
- *condition_bb, true_edge, false_edge,
- false /* Do not redirect all edges. */);
-
- exit = loop->single_exit;
- if (exit)
- nloop->single_exit = find_edge (exit->src->rbi->copy, exit->dest);
-
- /* loopify redirected latch_edge. Update its PENDING_STMTS. */
- flush_pending_stmts (latch_edge);
-
- /* loopify redirected condition_bb's succ edge. Update its PENDING_STMTS. */
- extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
- flush_pending_stmts (false_edge);
-
- /* Adjust irreducible flag. */
- if (irred_flag)
- {
- (*condition_bb)->flags |= BB_IRREDUCIBLE_LOOP;
- loop_preheader_edge (loop)->flags |= EDGE_IRREDUCIBLE_LOOP;
- loop_preheader_edge (nloop)->flags |= EDGE_IRREDUCIBLE_LOOP;
- single_pred_edge ((*condition_bb))->flags |= EDGE_IRREDUCIBLE_LOOP;
- }
-
- /* At this point condition_bb is loop predheader with two successors,
- first_head and second_head. Make sure that loop predheader has only
- one successor. */
- loop_split_edge_with (loop_preheader_edge (loop), NULL);
- loop_split_edge_with (loop_preheader_edge (nloop), NULL);
-
- return nloop;
-}