aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sink.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-05-21 08:11:23 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-05-21 08:11:23 +0000
commit7ec67e2af8d310e18dd894c9836c28254773bd0c (patch)
treed339da3c2c6b46c735d16b9256dc8f32814dc8fc /gcc/tree-ssa-sink.c
parent0e39213cbbfee526d6bae8675ebb454227edc44d (diff)
downloadgcc-7ec67e2af8d310e18dd894c9836c28254773bd0c.zip
gcc-7ec67e2af8d310e18dd894c9836c28254773bd0c.tar.gz
gcc-7ec67e2af8d310e18dd894c9836c28254773bd0c.tar.bz2
re PR tree-optimization/57303 (struct miscompiled at -O1 and above)
2013-05-21 Richard Biener <rguenther@suse.de> PR tree-optimization/57303 * tree-ssa-sink.c (statement_sink_location): Improve killing stmt detection and properly handle self-assignments. * gcc.dg/torture/pr57303.c: New testcase. From-SVN: r199135
Diffstat (limited to 'gcc/tree-ssa-sink.c')
-rw-r--r--gcc/tree-ssa-sink.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 0d9029b..87a0a59 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -331,11 +331,19 @@ statement_sink_location (gimple stmt, basic_block frombb,
gimple use_stmt = USE_STMT (use_p);
/* A killing definition is not a use. */
- if (gimple_assign_single_p (use_stmt)
- && gimple_vdef (use_stmt)
- && operand_equal_p (gimple_assign_lhs (stmt),
- gimple_assign_lhs (use_stmt), 0))
- continue;
+ if ((gimple_has_lhs (use_stmt)
+ && operand_equal_p (gimple_assign_lhs (stmt),
+ gimple_get_lhs (use_stmt), 0))
+ || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
+ {
+ /* If use_stmt is or might be a nop assignment then USE_STMT
+ acts as a use as well as definition. */
+ if (stmt != use_stmt
+ && ref_maybe_used_by_stmt_p (use_stmt,
+ gimple_assign_lhs (stmt)))
+ return false;
+ continue;
+ }
if (gimple_code (use_stmt) != GIMPLE_PHI)
return false;