re PR tree-optimization/71240 (ICE on valid code at -O2 and above on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Tue, 24 May 2016 14:40:35 +0000 (14:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 24 May 2016 14:40:35 +0000 (14:40 +0000)
2016-05-24  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71240
* tree-ssa-math-opts.c (init_symbolic_number): Verify the source
has integral type.

* gcc.dg/optimize-bswapsi-5.c: New testcase.

From-SVN: r236644

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/optimize-bswapsi-5.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 13134d91114962ecc24af25363fa5900321e5a76..45313abff88b3049ffdbe25a2f97ad39b2627bf7 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-24  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71240
+       * tree-ssa-math-opts.c (init_symbolic_number): Verify the source
+       has integral type.
+
 2016-05-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71230
index a6f65b87a1988c63cb0f2a0fd77b5383ce8b1f62..25decd38093276e6817f31118c44dc5cb18fdb7f 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-24  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71240
+       * gcc.dg/optimize-bswapsi-5.c: New testcase.
+
 2016-05-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71230
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c
new file mode 100644 (file)
index 0000000..a824547
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target bswap32 } */
+/* { dg-options "-O2 -fdump-tree-bswap" } */
+/* { dg-additional-options "-march=z900" { target s390-*-* } } */
+
+struct L { unsigned int l[2]; };
+union U { double a; struct L l; } u;
+
+void
+foo (double a, struct L *p)
+{
+  u.a = a;
+  struct L l = u.l, m;
+  m.l[0] = (((l.l[1] & 0xff000000) >> 24)
+           | ((l.l[1] & 0x00ff0000) >> 8)
+           | ((l.l[1] & 0x0000ff00) << 8)
+           | ((l.l[1] & 0x000000ff) << 24));
+  m.l[1] = (((l.l[0] & 0xff000000) >> 24)
+           | ((l.l[0] & 0x00ff0000) >> 8)
+           | ((l.l[0] & 0x0000ff00) << 8)
+           | ((l.l[0] & 0x000000ff) << 24));
+  *p = m;
+}
+
+void
+bar (double a, struct L *p)
+{
+  foo (a, p);
+}
+
+/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
index 81688cd096c387532ceb155f168cde25b4a431e2..0b0c86674f4bf24f680b7fb1e55b116372cba336 100644 (file)
@@ -2051,6 +2051,9 @@ init_symbolic_number (struct symbolic_number *n, tree src)
 {
   int size;
 
+  if (! INTEGRAL_TYPE_P (TREE_TYPE (src)))
+    return false;
+
   n->base_addr = n->offset = n->alias_set = n->vuse = NULL_TREE;
 
   /* Set up the symbolic number N by setting each byte to a value between 1 and