OSDN Git Service

2009-09-24 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Sep 2009 13:47:26 +0000 (13:47 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Sep 2009 13:47:26 +0000 (13:47 +0000)
PR tree-optimization/36143
PR tree-optimization/38747
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Only
create VIEW_CONVERT_EXPRs for TBAA compatible accesses.

* gcc.dg/tree-ssa/fre-vce-1.c: XFAIL.
* gcc.dg/tree-ssa/forwprop-6.c: Likewise.
* g++.dg/torture/pr38747.C: New testcase.
* g++.dg/tree-ssa/pr19637.C: Un-XFAIL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152122 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr38747.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/pr19637.C
gcc/testsuite/gcc.dg/tree-ssa/forwprop-6.c
gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c
gcc/tree-ssa-forwprop.c

index f2d49b6..000521b 100644 (file)
@@ -1,3 +1,10 @@
+2009-09-24  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/36143
+       PR tree-optimization/38747
+       * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Only
+       create VIEW_CONVERT_EXPRs for TBAA compatible accesses.
+
 2009-09-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/41457
index 5b6eee2..bf75ec2 100644 (file)
@@ -1,3 +1,12 @@
+2009-09-24  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/36143
+       PR tree-optimization/38747
+       * gcc.dg/tree-ssa/fre-vce-1.c: XFAIL.
+       * gcc.dg/tree-ssa/forwprop-6.c: Likewise.
+       * g++.dg/torture/pr38747.C: New testcase.
+       * g++.dg/tree-ssa/pr19637.C: Un-XFAIL.
+
 2009-09-24  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/nested_proc.adb: New test.
diff --git a/gcc/testsuite/g++.dg/torture/pr38747.C b/gcc/testsuite/g++.dg/torture/pr38747.C
new file mode 100644 (file)
index 0000000..0f18a2f
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+extern "C" void abort (void);
+inline void *operator new (__SIZE_TYPE__, void *__p) throw () { return __p; }
+
+int __attribute__((noinline))
+foo(void)
+{
+  float f = 0;
+  int *i = new (&f) int (1);
+  return *(int *)&f;
+}
+
+int main()
+{
+  if (foo() != 1)
+    abort ();
+  return 0;
+}
index cf70e40..2d1dcce 100644 (file)
@@ -29,6 +29,5 @@ int foo_void_offset(void)
   return reinterpret_cast<Foo *>(&i[0])->i[0];
 }
 
-/* Regarding the xfail, see PR36143.  */
-/* { dg-final { scan-tree-dump-times "return 1;" 3 "dom1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "return 1;" 3 "dom1" } } */
 /* { dg-final { cleanup-tree-dump "dom1" } } */
index 987f8a3..54e5109 100644 (file)
@@ -17,6 +17,11 @@ void f(void)
 }
 
 /* We should be able to convert the cast to a VCE in forwprop1,
-   even if there is an aliasing violation. */
-/* { dg-final { scan-tree-dump-times "VIEW_CONVERT_EXPR" 1 "forwprop1"} } */
+   even if there is an aliasing violation.
+   ???  While this would be useful and nice to our users in this
+   particular situation before doing this transformation we have to
+   assure that a is killed by a dominating store via type float for
+   it to be valid.  Then we might as well handle the situation by
+   value-numbering, removing the load alltogether.  */
+/* { dg-final { scan-tree-dump-times "VIEW_CONVERT_EXPR" 1 "forwprop1" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "forwprop1" } } */
index 2bc6da3..340f568 100644 (file)
@@ -32,6 +32,7 @@ void a2 (struct s1 sv, int i)
 }
 
 /* { dg-final { scan-tree-dump-times "sv_\[0-9\]\\\(D\\\)->i" 2 "fre" } } */
-/* { dg-final { scan-tree-dump-times "sv.i" 2 "fre" } } */
-
+/* We can't value-number *(float *)&sv.i as VIEW_CONVERT_EXPR of the
+   value of sv.i.  */
+/* { dg-final { scan-tree-dump-times "sv.i" 2 "fre" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "fre" } } */
index 5aec334..87795a2 100644 (file)
@@ -831,7 +831,9 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
       && !TYPE_VOLATILE (TREE_TYPE (rhs))
       && !TYPE_VOLATILE (TREE_TYPE (TREE_OPERAND (def_rhs, 0)))
       && operand_equal_p (TYPE_SIZE (TREE_TYPE (rhs)),
-                         TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))), 0)) 
+                         TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))), 0)
+      /* Make sure we only do TBAA compatible replacements.  */
+      && get_alias_set (TREE_OPERAND (def_rhs, 0)) == get_alias_set (rhs))
    {
      tree def_rhs_base, new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
      new_rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), new_rhs);