Commit a2159c4c by Devang Patel Committed by Devang Patel

tree-if-conv.c (tree_if_convert_cond_expr0): Create temp.

       * tree-if-conv.c (tree_if_convert_cond_expr0: Create temp. variable
       only when necesssary.
       (combine_blocks): Combine loop header and exit block.

From-SVN: r88062
parent c0c07d7b
2004-09-24 Devang Patel <dpatel@apple.com>
* tree-if-conv.c (tree_if_convert_cond_expr0: Create temp. variable
only when necesssary.
(combine_blocks): Combine loop header and exit block.
2004-09-24 Paolo Bonzini <bonzini@gnu.org> 2004-09-24 Paolo Bonzini <bonzini@gnu.org>
* hooks.c (hook_tree_tree_bool_null): New. * hooks.c (hook_tree_tree_bool_null): New.
......
...@@ -281,7 +281,7 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond, ...@@ -281,7 +281,7 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond,
else_clause = TREE_OPERAND (stmt, 2); else_clause = TREE_OPERAND (stmt, 2);
/* Create temp. for condition. */ /* Create temp. for condition. */
if (!is_gimple_reg (c)) if (!is_gimple_condexpr (c))
{ {
tree new_stmt; tree new_stmt;
new_stmt = ifc_temp_var (TREE_TYPE (c), unshare_expr (c)); new_stmt = ifc_temp_var (TREE_TYPE (c), unshare_expr (c));
...@@ -292,14 +292,22 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond, ...@@ -292,14 +292,22 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond,
/* Add new condition into destination's predicate list. */ /* Add new condition into destination's predicate list. */
if (then_clause) if (then_clause)
/* if 'c' is true then then_clause is reached. */ /* if 'c' is true then then_clause is reached. */
new_cond = add_to_dst_predicate_list (loop, then_clause, cond, c, bsi); new_cond = add_to_dst_predicate_list (loop, then_clause, cond,
unshare_expr (c), bsi);
if (else_clause) if (else_clause)
{ {
tree c2;
if (!is_gimple_reg(c) && is_gimple_condexpr (c))
{
tree new_stmt;
new_stmt = ifc_temp_var (TREE_TYPE (c), unshare_expr (c));
bsi_insert_before (bsi, new_stmt, BSI_SAME_STMT);
c = TREE_OPERAND (new_stmt, 0);
}
/* if 'c' is false then else_clause is reached. */ /* if 'c' is false then else_clause is reached. */
tree c2 = build1 (TRUTH_NOT_EXPR, c2 = invert_truthvalue (unshare_expr (c));
boolean_type_node,
unshare_expr (c));
add_to_dst_predicate_list (loop, else_clause, cond, c2, bsi); add_to_dst_predicate_list (loop, else_clause, cond, c2, bsi);
} }
...@@ -311,11 +319,6 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond, ...@@ -311,11 +319,6 @@ tree_if_convert_cond_expr (struct loop *loop, tree stmt, tree cond,
bsi_remove (bsi); bsi_remove (bsi);
cond = NULL_TREE; cond = NULL_TREE;
} }
else if (new_cond != NULL_TREE)
{
TREE_OPERAND (stmt, 0) = new_cond;
modify_stmt (stmt);
}
return; return;
} }
...@@ -917,6 +920,18 @@ combine_blocks (struct loop *loop) ...@@ -917,6 +920,18 @@ combine_blocks (struct loop *loop)
remove_bb_from_loops (bb); remove_bb_from_loops (bb);
expunge_block (bb); expunge_block (bb);
} }
/* Now if possible, merge loop header and block with exit edge.
This reduces number of basic blocks to 2. Auto vectorizer addresses
loops with two nodes only. FIXME: Use cleanup_tree_cfg(). */
if (exit_bb != loop->latch && empty_block_p (loop->latch))
{
if (can_merge_blocks_p (loop->header, exit_bb))
{
remove_bb_from_loops (exit_bb);
merge_blocks (loop->header, exit_bb);
}
}
} }
/* Make new temp variable of type TYPE. Add MODIFY_EXPR to assign EXP /* Make new temp variable of type TYPE. Add MODIFY_EXPR to assign EXP
......
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