summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-06 14:54:47 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-06 14:54:47 +0000
commitf509e77834812ee1dfa09ddaea8ca588934cb951 (patch)
tree9c8b602a7561843e42fb61606d5daa0659ca8d88
parentc86dbacda4b6e5c8b7271207cb3db7bef6ef829a (diff)
downloadgcc-f509e77834812ee1dfa09ddaea8ca588934cb951.tar.gz
2012-02-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52115 * tree-sra.c (access_has_replacements_p): New function. (sra_modify_assign): Use it to decide whether a use is uninitialized. * gcc.c-torture/compile/pr52115.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183937 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr52115.c26
-rw-r--r--gcc/tree-sra.c19
4 files changed, 53 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bf5e93b3f78..28f130f3501 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-06 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/52115
+ * tree-sra.c (access_has_replacements_p): New function.
+ (sra_modify_assign): Use it to decide whether a use is uninitialized.
+
2012-02-06 Patrick Marlier <patrick.marlier@gmail.com>
PR middle-end/52047
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6361ab0e0e5..305a6894795 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-02-06 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/52115
+ * gcc.c-torture/compile/pr52115.c: New testcase.
+
2012-02-06 Jakub Jelinek <jakub@redhat.com>
PR target/52129
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52115.c b/gcc/testsuite/gcc.c-torture/compile/pr52115.c
new file mode 100644
index 00000000000..789d08f4d98
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr52115.c
@@ -0,0 +1,26 @@
+struct S
+{
+ float f;
+ long l;
+};
+
+extern int gi;
+extern float gf;
+
+long foo (long p)
+{
+ struct S s;
+ float *pf;
+
+ s.l = p;
+
+ pf = &s.f;
+
+ pf++;
+ pf--;
+
+ gf = *pf + 3.3;
+ gi = *((short *)pf) + 2;
+
+ return s.l + 6;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index e3bf38230dc..e2091e5fda4 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -440,6 +440,20 @@ access_has_children_p (struct access *acc)
return acc && acc->first_child;
}
+/* Return true iff ACC is (partly) covered by at least one replacement. */
+
+static bool
+access_has_replacements_p (struct access *acc)
+{
+ struct access *child;
+ if (acc->grp_to_be_replaced)
+ return true;
+ for (child = acc->first_child; child; child = child->next_sibling)
+ if (access_has_replacements_p (child))
+ return true;
+ return false;
+}
+
/* Return a vector of pointers to accesses for the variable given in BASE or
NULL if there is none. */
@@ -2992,10 +3006,9 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
sra_stats.exprs++;
}
else if (racc
- && !access_has_children_p (racc)
- && !racc->grp_to_be_replaced
&& !racc->grp_unscalarized_data
- && TREE_CODE (lhs) == SSA_NAME)
+ && TREE_CODE (lhs) == SSA_NAME
+ && !access_has_replacements_p (racc))
{
rhs = get_repl_default_def_ssa_name (racc);
modify_this_stmt = true;