aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-if-conv.c
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@amd.com>2011-01-25 14:51:23 +0000
committerSebastian Pop <spop@gcc.gnu.org>2011-01-25 14:51:23 +0000
commitdb963b528702d92bb843ff50f8d7a3d7fb34257d (patch)
treea0d39d42e2fe0300dd15f8f54888f83ac348c280 /gcc/tree-if-conv.c
parentbcddd3b99ca8aecbe9fe7afbf53548f9adc1498c (diff)
downloadgcc-db963b528702d92bb843ff50f8d7a3d7fb34257d.zip
gcc-db963b528702d92bb843ff50f8d7a3d7fb34257d.tar.gz
gcc-db963b528702d92bb843ff50f8d7a3d7fb34257d.tar.bz2
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. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r169233
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 46b20c2..ca8f84a 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);