Commit 7f7e0703 by Devang Patel Committed by Devang Patel

tree-if-conv.c (find_phi_replacement_condition): Return true edge block.

        * tree-if-conv.c (find_phi_replacement_condition): Return true edge block.
        (replace_phi_with_cond_modify_expr): Select conditional expr args based on
        true edge basic block.

From-SVN: r87194
parent ed7f7d85
2004-09-08 Devang Patel <dpatel@apple.com>
* tree-if-conv.c (find_phi_replacement_condition): Return true edge block.
(replace_phi_with_cond_modify_expr): Select conditional expr args based on
true edge basic block.
2004-09-08 Jan Hubicka <jh@suse.cz> 2004-09-08 Jan Hubicka <jh@suse.cz>
* tree-ssa-operands.c (add_stmt_operand): Use V_MUST_DEF even for * tree-ssa-operands.c (add_stmt_operand): Use V_MUST_DEF even for
......
...@@ -117,9 +117,9 @@ static void add_to_predicate_list (basic_block, tree); ...@@ -117,9 +117,9 @@ static void add_to_predicate_list (basic_block, tree);
static tree add_to_dst_predicate_list (struct loop * loop, tree, tree, tree, static tree add_to_dst_predicate_list (struct loop * loop, tree, tree, tree,
block_stmt_iterator *); block_stmt_iterator *);
static void clean_predicate_lists (struct loop *loop); static void clean_predicate_lists (struct loop *loop);
static bool find_phi_replacement_condition (basic_block, tree *, static basic_block find_phi_replacement_condition (basic_block, tree *,
block_stmt_iterator *); block_stmt_iterator *);
static void replace_phi_with_cond_modify_expr (tree, tree, bool, static void replace_phi_with_cond_modify_expr (tree, tree, basic_block,
block_stmt_iterator *); block_stmt_iterator *);
static void process_phi_nodes (struct loop *); static void process_phi_nodes (struct loop *);
static void combine_blocks (struct loop *); static void combine_blocks (struct loop *);
...@@ -671,17 +671,17 @@ clean_predicate_lists (struct loop *loop) ...@@ -671,17 +671,17 @@ clean_predicate_lists (struct loop *loop)
} }
/* Basic block BB has two predecessors. Using predecessor's aux field, set /* Basic block BB has two predecessors. Using predecessor's aux field, set
appropriate condition COND for the PHI node replacement. Return true if appropriate condition COND for the PHI node replacement. Return true block
phi arguments are condition is selected from second predecessor. */ whose phi arguments are selected when cond is true. */
static bool static basic_block
find_phi_replacement_condition (basic_block bb, tree *cond, find_phi_replacement_condition (basic_block bb, tree *cond,
block_stmt_iterator *bsi) block_stmt_iterator *bsi)
{ {
edge e; edge e;
basic_block p1 = NULL; basic_block p1 = NULL;
basic_block p2 = NULL; basic_block p2 = NULL;
bool switch_args = false; basic_block true_bb = NULL;
tree tmp_cond; tree tmp_cond;
for (e = bb->pred; e; e = e->pred_next) for (e = bb->pred; e; e = e->pred_next)
...@@ -700,12 +700,12 @@ find_phi_replacement_condition (basic_block bb, tree *cond, ...@@ -700,12 +700,12 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR) if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
{ {
*cond = p2->aux; *cond = p2->aux;
switch_args = true; true_bb = p2;
} }
else else
{ {
*cond = p1->aux; *cond = p1->aux;
switch_args = false; true_bb = p1;
} }
/* Create temp. for the condition. Vectorizer prefers to have gimple /* Create temp. for the condition. Vectorizer prefers to have gimple
...@@ -727,7 +727,7 @@ find_phi_replacement_condition (basic_block bb, tree *cond, ...@@ -727,7 +727,7 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
abort (); abort ();
#endif #endif
return switch_args; return true_bb;
} }
...@@ -738,11 +738,11 @@ find_phi_replacement_condition (basic_block bb, tree *cond, ...@@ -738,11 +738,11 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
is converted into, is converted into,
S2: A = cond ? x1 : x2; S2: A = cond ? x1 : x2;
S2 is inserted at the top of basic block's statement list. S2 is inserted at the top of basic block's statement list.
PHI arguments are switched if SWITCH_ARGS is true. When COND is true, phi arg from TRUE_BB is selected.
*/ */
static void static void
replace_phi_with_cond_modify_expr (tree phi, tree cond, bool switch_args, replace_phi_with_cond_modify_expr (tree phi, tree cond, basic_block true_bb,
block_stmt_iterator *bsi) block_stmt_iterator *bsi)
{ {
tree new_stmt; tree new_stmt;
...@@ -767,7 +767,7 @@ replace_phi_with_cond_modify_expr (tree phi, tree cond, bool switch_args, ...@@ -767,7 +767,7 @@ replace_phi_with_cond_modify_expr (tree phi, tree cond, bool switch_args,
arg_1 = NULL_TREE; arg_1 = NULL_TREE;
/* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr. */ /* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr. */
if (switch_args) if (PHI_ARG_EDGE(phi, 1)->src == true_bb)
{ {
arg_0 = PHI_ARG_DEF (phi, 1); arg_0 = PHI_ARG_DEF (phi, 1);
arg_1 = PHI_ARG_DEF (phi, 0); arg_1 = PHI_ARG_DEF (phi, 0);
...@@ -820,7 +820,7 @@ process_phi_nodes (struct loop *loop) ...@@ -820,7 +820,7 @@ process_phi_nodes (struct loop *loop)
{ {
tree phi, cond; tree phi, cond;
block_stmt_iterator bsi; block_stmt_iterator bsi;
bool switch_args = false; basic_block true_bb = NULL;
bb = ifc_bbs[i]; bb = ifc_bbs[i];
if (bb == loop->header || bb == loop->latch) if (bb == loop->header || bb == loop->latch)
...@@ -832,12 +832,12 @@ process_phi_nodes (struct loop *loop) ...@@ -832,12 +832,12 @@ process_phi_nodes (struct loop *loop)
/* BB has two predecessors. Using predecessor's aux field, set /* BB has two predecessors. Using predecessor's aux field, set
appropriate condition for the PHI node replacement. */ appropriate condition for the PHI node replacement. */
if (phi) if (phi)
switch_args = find_phi_replacement_condition (bb, &cond, &bsi); true_bb = find_phi_replacement_condition (bb, &cond, &bsi);
while (phi) while (phi)
{ {
tree next = TREE_CHAIN (phi); tree next = TREE_CHAIN (phi);
replace_phi_with_cond_modify_expr (phi, cond, switch_args, &bsi); replace_phi_with_cond_modify_expr (phi, cond, true_bb, &bsi);
release_phi_node (phi); release_phi_node (phi);
phi = next; phi = next;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment