summaryrefslogtreecommitdiff
path: root/gcc/tree-if-conv.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-25 14:51:23 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-25 14:51:23 +0000
commit5790abbc74a3439158a53e1f8ae6848111088ced (patch)
treea0d39d42e2fe0300dd15f8f54888f83ac348c280 /gcc/tree-if-conv.c
parent02f06d230fff4d40d93bf2da0d64a81aff4ce507 (diff)
downloadgcc-5790abbc74a3439158a53e1f8ae6848111088ced.tar.gz
Fix PR47271: only if-convert full writes.
2011-01-25 Sebastian Pop <sebastian.pop@amd.com> Jakub Jelinek <jakub@redhat.com> PR tree-optimization/47271 * tree-if-conv.c (bb_postdominates_preds): New. (if_convertible_bb_p): Call bb_postdominates_preds. (if_convertible_loop_p_1): Compute CDI_POST_DOMINATORS. (predicate_scalar_phi): Call bb_postdominates_preds. * gcc.dg/tree-ssa/ifc-pr47271.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169233 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-if-conv.c')
-rw-r--r--gcc/tree-if-conv.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 46b20c26c19..ca8f84a54cf 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -716,6 +716,20 @@ if_convertible_stmt_p (gimple stmt, VEC (data_reference_p, heap) *refs)
return true;
}
+/* Return true when BB post-dominates all its predecessors. */
+
+static bool
+bb_postdominates_preds (basic_block bb)
+{
+ unsigned i;
+
+ for (i = 0; i < EDGE_COUNT (bb->preds); i++)
+ if (!dominated_by_p (CDI_POST_DOMINATORS, EDGE_PRED (bb, i)->src, bb))
+ return false;
+
+ return true;
+}
+
/* Return true when BB is if-convertible. This routine does not check
basic block's statements and phis.
@@ -774,6 +788,11 @@ if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb)
return false;
}
+ if (EDGE_COUNT (bb->preds) == 2
+ && bb != loop->header
+ && !bb_postdominates_preds (bb))
+ return false;
+
return true;
}
@@ -992,6 +1011,7 @@ if_convertible_loop_p_1 (struct loop *loop,
return false;
calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_POST_DOMINATORS);
/* Allow statements that can be handled during if-conversion. */
ifc_bbs = get_loop_body_in_if_conv_order (loop);
@@ -1262,6 +1282,9 @@ predicate_scalar_phi (gimple phi, tree cond,
arg_1 = gimple_phi_arg_def (phi, 1);
}
+ gcc_checking_assert (bb == bb->loop_father->header
+ || bb_postdominates_preds (bb));
+
/* Build new RHS using selected condition and arguments. */
rhs = build3 (COND_EXPR, TREE_TYPE (res),
unshare_expr (cond), arg_0, arg_1);