re PR tree-optimization/37868 (code that breaks TBAA is misoptimized even with -fno...
authorRichard Guenther <rguenther@suse.de>
Thu, 20 Nov 2008 12:25:26 +0000 (12:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 20 Nov 2008 12:25:26 +0000 (12:25 +0000)
2008-11-20  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/37868
* gcc.dg/torture/pr37868.c: New testcase.
* gcc.c-torture/execute/pr38048-1.c: Likewise.
* gcc.c-torture/execute/pr38048-2.c: Likewise.

From-SVN: r142041

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr38048-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr38048-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr37868.c [new file with mode: 0644]

index 1a543e5..569accd 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-20  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37868
+       * gcc.dg/torture/pr37868.c: New testcase.
+       * gcc.c-torture/execute/pr38048-1.c: Likewise.
+       * gcc.c-torture/execute/pr38048-2.c: Likewise.
+
 2008-11-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/38181
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c b/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c
new file mode 100644 (file)
index 0000000..b87363f
--- /dev/null
@@ -0,0 +1,22 @@
+extern void abort(void);
+
+int foo ()
+{
+  int mat[2][1];
+  int (*a)[1] = mat;
+  int det = 0;
+  int i;
+  mat[0][0] = 1;
+  mat[1][0] = 2;
+  for (i = 0; i < 2; ++i)
+    det += a[i][0];
+  return det;
+}
+
+int main()
+{
+  if (foo () != 3)
+    abort ();
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c b/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c
new file mode 100644 (file)
index 0000000..f4fe40c
--- /dev/null
@@ -0,0 +1,28 @@
+extern void abort (void);
+
+static int inv_J(int a[][2])
+{
+  int i, j;
+  int det = 0.0;
+   for (j=0; j<2; ++j)
+     det += a[j][0] + a[j][1];
+  return det;
+}
+
+int foo()
+{
+  int mat[2][2];
+  mat[0][0] = 1;
+  mat[0][1] = 2;
+  mat[1][0] = 4;
+  mat[1][1] = 8;
+  return inv_J(mat);
+}
+
+int main()
+{
+  if (foo () != 15)
+    abort ();
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr37868.c b/gcc/testsuite/gcc.dg/torture/pr37868.c
new file mode 100644 (file)
index 0000000..85c2b50
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-fno-strict-aliasing" } */
+
+extern void abort (void);
+
+struct X {
+  unsigned char pad : 4;
+  unsigned int a : 32;
+  unsigned int b : 24;
+  unsigned int c : 6;
+} __attribute__((packed));
+
+int main (void)
+{
+  struct X x;
+  unsigned int bad_bits;
+
+  x.pad = -1;
+  x.a = -1;
+  x.b = -1;
+  x.c = -1;
+
+  bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x);
+  if (bad_bits != 0)
+    abort ();
+  return 0;
+}
+