]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2012-02-06 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Feb 2012 14:54:47 +0000 (14:54 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Feb 2012 14:54:47 +0000 (14:54 +0000)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr52115.c [new file with mode: 0644]
gcc/tree-sra.c

index bf5e93b3f783b983f96dfd3024d5e515a4c6ad84..28f130f35011fc52563353f2511bbb7d341476e0 100644 (file)
@@ -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
index 6361ab0e0e5c8ff458bdb488ce2146b2d7432495..305a689479561798ef07f94477bd753931968f63 100644 (file)
@@ -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 (file)
index 0000000..789d08f
--- /dev/null
@@ -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;
+}
index e3bf38230dc7d4180f4e98060eaf5ced9dc5ad08..e2091e5fda49cec2ea82c3c95e22dbddcd543c16 100644 (file)
@@ -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;