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
This commit is contained in:
Devang Patel 2004-09-08 11:25:01 -07:00 committed by Devang Patel
parent ed7f7d851c
commit 7f7e070310
2 changed files with 23 additions and 17 deletions

View File

@ -1,3 +1,9 @@
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>
* tree-ssa-operands.c (add_stmt_operand): Use V_MUST_DEF even for

View File

@ -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,
block_stmt_iterator *);
static void clean_predicate_lists (struct loop *loop);
static bool find_phi_replacement_condition (basic_block, tree *,
block_stmt_iterator *);
static void replace_phi_with_cond_modify_expr (tree, tree, bool,
static basic_block find_phi_replacement_condition (basic_block, tree *,
block_stmt_iterator *);
static void replace_phi_with_cond_modify_expr (tree, tree, basic_block,
block_stmt_iterator *);
static void process_phi_nodes (struct loop *);
static void combine_blocks (struct loop *);
@ -671,17 +671,17 @@ clean_predicate_lists (struct loop *loop)
}
/* Basic block BB has two predecessors. Using predecessor's aux field, set
appropriate condition COND for the PHI node replacement. Return true if
phi arguments are condition is selected from second predecessor. */
appropriate condition COND for the PHI node replacement. Return true block
whose phi arguments are selected when cond is true. */
static bool
static basic_block
find_phi_replacement_condition (basic_block bb, tree *cond,
block_stmt_iterator *bsi)
{
edge e;
basic_block p1 = NULL;
basic_block p2 = NULL;
bool switch_args = false;
basic_block true_bb = NULL;
tree tmp_cond;
for (e = bb->pred; e; e = e->pred_next)
@ -700,12 +700,12 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
{
*cond = p2->aux;
switch_args = true;
true_bb = p2;
}
else
{
*cond = p1->aux;
switch_args = false;
true_bb = p1;
}
/* Create temp. for the condition. Vectorizer prefers to have gimple
@ -727,7 +727,7 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
abort ();
#endif
return switch_args;
return true_bb;
}
@ -738,18 +738,18 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
is converted into,
S2: A = cond ? x1 : x2;
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
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)
{
tree new_stmt;
basic_block bb;
tree rhs;
tree arg_0, arg_1;
#ifdef ENABLE_CHECKING
if (TREE_CODE (phi) != PHI_NODE)
abort ();
@ -767,7 +767,7 @@ replace_phi_with_cond_modify_expr (tree phi, tree cond, bool switch_args,
arg_1 = NULL_TREE;
/* 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_1 = PHI_ARG_DEF (phi, 0);
@ -820,7 +820,7 @@ process_phi_nodes (struct loop *loop)
{
tree phi, cond;
block_stmt_iterator bsi;
bool switch_args = false;
basic_block true_bb = NULL;
bb = ifc_bbs[i];
if (bb == loop->header || bb == loop->latch)
@ -832,12 +832,12 @@ process_phi_nodes (struct loop *loop)
/* BB has two predecessors. Using predecessor's aux field, set
appropriate condition for the PHI node replacement. */
if (phi)
switch_args = find_phi_replacement_condition (bb, &cond, &bsi);
true_bb = find_phi_replacement_condition (bb, &cond, &bsi);
while (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);
phi = next;
}