summaryrefslogtreecommitdiff
path: root/gcc/tree-loop-distribution.c
diff options
context:
space:
mode:
authortomby <tomby@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-12 15:37:09 +0000
committertomby <tomby@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-12 15:37:09 +0000
commita6c1b5f02c8678f45eeb450600cdd87456146b46 (patch)
treee1e3f644a0682e8328a8ea1037b43d04118503c4 /gcc/tree-loop-distribution.c
parent3a43bfe92a316520f682bf513990bbd8b8942854 (diff)
downloadgcc-a6c1b5f02c8678f45eeb450600cdd87456146b46.tar.gz
PR middlend/38385
* tree-loop-distribution.c (prop_phis): New function. (generate_builtin): Call prop_phis. * testsuite/gcc.dg/tree-ssa/pr38385.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143291 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-loop-distribution.c')
-rw-r--r--gcc/tree-loop-distribution.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 062ab48ee7e..745957fcea2 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -331,6 +331,38 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
return res;
}
+/* Propagate phis in BB b to their uses and remove them. */
+
+static void
+prop_phis (basic_block b)
+{
+ gimple_stmt_iterator psi;
+ gimple_seq phis = phi_nodes (b);
+
+ for (psi = gsi_start (phis); !gsi_end_p (psi); )
+ {
+ gimple phi = gsi_stmt (psi);
+ tree def = gimple_phi_result (phi), use = gimple_phi_arg_def (phi, 0);
+
+ gcc_assert (gimple_phi_num_args (phi) == 1);
+
+ if (!is_gimple_reg (def))
+ {
+ imm_use_iterator iter;
+ use_operand_p use_p;
+ gimple stmt;
+
+ FOR_EACH_IMM_USE_STMT (stmt, iter, def)
+ FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ SET_USE (use_p, use);
+ }
+ else
+ replace_uses_by (def, use);
+
+ remove_phi_node (&psi, true);
+ }
+}
+
/* Tries to generate a builtin function for the instructions of LOOP
pointed to by the bits set in PARTITION. Returns true when the
operation succeeded. */
@@ -400,6 +432,7 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p)
unsigned nbbs = loop->num_nodes;
basic_block src = loop_preheader_edge (loop)->src;
basic_block dest = single_exit (loop)->dest;
+ prop_phis (dest);
make_edge (src, dest, EDGE_FALLTHRU);
set_immediate_dominator (CDI_DOMINATORS, dest, src);
cancel_loop_tree (loop);