The following fixes the ICEs in PR71230.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-05-24  Richard Biener  <rguent...@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.

Index: gcc/tree-ssa-math-opts.c
===================================================================
*** gcc/tree-ssa-math-opts.c    (revision 236630)
--- gcc/tree-ssa-math-opts.c    (working copy)
*************** init_symbolic_number (struct symbolic_nu
*** 2051,2056 ****
--- 2051,2059 ----
  {
    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
Index: gcc/testsuite/gcc.dg/optimize-bswapsi-5.c
===================================================================
*** gcc/testsuite/gcc.dg/optimize-bswapsi-5.c   (revision 0)
--- gcc/testsuite/gcc.dg/optimize-bswapsi-5.c   (working copy)
***************
*** 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" } } */

Reply via email to