From f1bcb061d172ca7e3bdcc46476b20776382a2974 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 17 May 2018 13:42:21 +0000 Subject: [PATCH] tree-ssa-dse.c (dse_classify_store): Fix iterator increment for pruning loop and prune defs feeding only already... 2018-05-17 Richard Biener * tree-ssa-dse.c (dse_classify_store): Fix iterator increment for pruning loop and prune defs feeding only already visited PHIs. From-SVN: r260322 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-dse.c | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a800a775ce..3c59e090972 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-05-17 Richard Biener + + * tree-ssa-dse.c (dse_classify_store): Fix iterator increment + for pruning loop and prune defs feeding only already visited PHIs. + 2018-05-17 Richard Biener * tree-ssa-sccvn.c (vn_reference_lookup_3): Improve memset handling. diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 589cfef5df5..1af50a02674 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -662,7 +662,7 @@ dse_classify_store (ao_ref *ref, gimple *stmt, } /* Process defs and remove those we need not process further. */ - for (unsigned i = 0; i < defs.length (); ++i) + for (unsigned i = 0; i < defs.length ();) { gimple *def = defs[i]; gimple *use_stmt; @@ -680,11 +680,18 @@ dse_classify_store (ao_ref *ref, gimple *stmt, /* In addition to kills we can remove defs whose only use is another def in defs. That can only ever be PHIs of which we track a single for simplicity reasons (we fail for multiple - PHIs anyways). */ + PHIs anyways). We can also ignore defs that feed only into + already visited PHIs. */ else if (gimple_code (def) != GIMPLE_PHI && single_imm_use (gimple_vdef (def), &use_p, &use_stmt) - && use_stmt == phi_def) + && (use_stmt == phi_def + || (gimple_code (use_stmt) == GIMPLE_PHI + && bitmap_bit_p (visited, + SSA_NAME_VERSION + (PHI_RESULT (use_stmt)))))) defs.unordered_remove (i); + else + ++i; } /* If all defs kill the ref we are done. */ -- 2.30.2