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 *);
}
/* 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)
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
abort ();
#endif
- return switch_args;
+ return true_bb;
}
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 ();
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);
{
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)
/* 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;
}