aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-11-20 12:25:26 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-11-20 12:25:26 +0000
commit32427faa01cbbd3ad3c113c55dd40922f66d75e4 (patch)
treef93fced54f126285756d5903a3df624e3e7fe4c3
parentb41b10e590e2b8b00dc5677520637540378251a0 (diff)
downloadgcc-32427faa01cbbd3ad3c113c55dd40922f66d75e4.zip
gcc-32427faa01cbbd3ad3c113c55dd40922f66d75e4.tar.gz
gcc-32427faa01cbbd3ad3c113c55dd40922f66d75e4.tar.bz2
re PR tree-optimization/37868 (code that breaks TBAA is misoptimized even with -fno-strict-aliasing)
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
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr38048-1.c22
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr38048-2.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr37868.c28
4 files changed, 85 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1a543e5..569accd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..b87363f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c
@@ -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
index 0000000..f4fe40c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c
@@ -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
index 0000000..85c2b50
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr37868.c
@@ -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;
+}
+