From 7f7e0703105e0ba185eb29beba29e55964b48f55 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 8 Sep 2004 11:25:01 -0700 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 ++++++ gcc/tree-if-conv.c | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 348924547ca..3108964bfa2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-09-08 Devang Patel + + * 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 * tree-ssa-operands.c (add_stmt_operand): Use V_MUST_DEF even for diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index daca885f64a..1e2fd76e3a9 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -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; } -- 2.30.2