diff options
author | Richard Biener <rguenther@suse.de> | 2014-02-15 09:54:52 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-02-15 09:54:52 +0000 |
commit | a2b33cc36b5a722130092adeb0b7225adcf35133 (patch) | |
tree | 7a30553f9d64251395dbf70303ce151ece8c2cce /gcc/tree-ssa-phiprop.c | |
parent | cd7734ca9e744ca6155e87c1f11dd4293c46b937 (diff) | |
download | gcc-a2b33cc36b5a722130092adeb0b7225adcf35133.zip gcc-a2b33cc36b5a722130092adeb0b7225adcf35133.tar.gz gcc-a2b33cc36b5a722130092adeb0b7225adcf35133.tar.bz2 |
re PR tree-optimization/60183 (phiprop creates invalid code)
2014-02-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/60183
* tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
loads.
(tree_ssa_phiprop): Calculate and free post-dominators.
* gcc.dg/torture/pr60183.c: New testcase.
From-SVN: r207797
Diffstat (limited to 'gcc/tree-ssa-phiprop.c')
-rw-r--r-- | gcc/tree-ssa-phiprop.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index bf2dcdb..4d66c12 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -309,6 +309,12 @@ propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn, gimple def_stmt; tree vuse; + /* Only replace loads in blocks that post-dominate the PHI node. That + makes sure we don't end up speculating loads. */ + if (!dominated_by_p (CDI_POST_DOMINATORS, + bb, gimple_bb (use_stmt))) + continue; + /* Check whether this is a load of *ptr. */ if (!(is_gimple_assign (use_stmt) && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME @@ -380,6 +386,7 @@ tree_ssa_phiprop (void) size_t n; calculate_dominance_info (CDI_DOMINATORS); + calculate_dominance_info (CDI_POST_DOMINATORS); n = num_ssa_names; phivn = XCNEWVEC (struct phiprop_d, n); @@ -397,6 +404,8 @@ tree_ssa_phiprop (void) bbs.release (); free (phivn); + free_dominance_info (CDI_POST_DOMINATORS); + return 0; } |