aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2005-12-16 00:03:12 -0700
committerJeff Law <law@gcc.gnu.org>2005-12-16 00:03:12 -0700
commit7d48c9e2cc0d77630d365efe8fa1803a224a9a0a (patch)
tree88a7799c9f4d7f31317de3ae132949f5dde781d1 /gcc/tree-ssa-dse.c
parent9a8ce21f3b47a109b9ac35239e21198bb36e1146 (diff)
downloadgcc-7d48c9e2cc0d77630d365efe8fa1803a224a9a0a.zip
gcc-7d48c9e2cc0d77630d365efe8fa1803a224a9a0a.tar.gz
gcc-7d48c9e2cc0d77630d365efe8fa1803a224a9a0a.tar.bz2
tree-ssa-dse.c (dse_optimize_stmt): Correctly handle PHI nodes which represent a use and definition of the same...
* tree-ssa-dse.c (dse_optimize_stmt): Correctly handle PHI nodes which represent a use and definition of the same SSA_NAME. * gcc.dg/tree-ssa/ssa-dse-8.c: New test. From-SVN: r108630
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index fa3ba96..f1cc22a 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -309,6 +309,15 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
&& TREE_CODE (use_stmt) == PHI_NODE
&& bitmap_bit_p (dse_gd->stores, get_stmt_uid (use_stmt)))
{
+ /* A PHI node can both define and use the same SSA_NAME if
+ the PHI is at the top of a loop and the PHI_RESULT is
+ a loop invariant and copies have not been fully propagated.
+
+ The safe thing to do is exit assuming no optimization is
+ possible. */
+ if (SSA_NAME_DEF_STMT (PHI_RESULT (use_stmt)) == use_stmt)
+ return;
+
/* Skip past this PHI and loop again in case we had a PHI
chain. */
if (single_imm_use (PHI_RESULT (use_stmt), &use_p, &use_stmt))