[PATCH] Fix PR67278

2016-03-01 Thread Richard Biener

The following fixes a checking issue when verifying BIT_FIELD_REF
sizes of non-integral non-BLKmode types.  We should be using
MODE_SIZE, not MODE_PRECISION here as seen with the testcase.

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

typedef long double a __attribute__((vector_size (32)));

still explodes in our face - I suppose backends need to have
a lever to what we allow as component types here (after all
they define the ABI for this kind of stuff - or fail to ;))

Richard.

2016-03-01  Richard Biener  

PR middle-end/67278
* tree-cfg.c (verify_expr): Adjust BIT_FIELD_REF case.

* gcc.dg/simd-7.c: New testcase.

Index: gcc/tree-cfg.c
===
--- gcc/tree-cfg.c  (revision 233852)
+++ gcc/tree-cfg.c  (working copy)
@@ -2959,10 +2959,10 @@ verify_expr (tree *tp, int *walk_subtree
}
  else if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   && TYPE_MODE (TREE_TYPE (t)) != BLKmode
-  && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t)))
+  && (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t)))
   != tree_to_uhwi (t1)))
{
- error ("mode precision of non-integral result does not "
+ error ("mode size of non-integral result does not "
 "match field size of BIT_FIELD_REF");
  return t;
}
Index: gcc/testsuite/gcc.dg/simd-7.c
===
--- gcc/testsuite/gcc.dg/simd-7.c   (revision 0)
+++ gcc/testsuite/gcc.dg/simd-7.c   (working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8
+typedef long double a __attribute__((vector_size (16)));
+
+a __attribute__((noinline))
+sum (a first, a second)
+{
+return first + second;
+}
+
+a
+foo (a x, a y, a z)
+{
+  return sum (x, y) + z;
+}
+#endif


Re: [PATCH] Fix PR67278

2016-03-08 Thread Andreas Schwab
Richard Biener  writes:

> Index: gcc/testsuite/gcc.dg/simd-7.c
> ===
> --- gcc/testsuite/gcc.dg/simd-7.c (revision 0)
> +++ gcc/testsuite/gcc.dg/simd-7.c (working copy)
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +
> +#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8
> +typedef long double a __attribute__((vector_size (16)));
> +
> +a __attribute__((noinline))
> +sum (a first, a second)
> +{
> +return first + second;
> +}
> +
> +a
> +foo (a x, a y, a z)
> +{
> +  return sum (x, y) + z;
> +}
> +#endif

On powerpc -m32:

FAIL: gcc.dg/simd-7.c (test for excess errors)
Excess errors:
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-7.c:8:1: warning: GCC vector 
returned by reference: non-standard ABI extension with no compatibility 
guarantee
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-7.c:7:1: warning: GCC vector 
passed by reference: non-standard ABI extension with no compatibility guarantee

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [PATCH] Fix PR67278

2016-03-09 Thread Jakub Jelinek
On Tue, Mar 08, 2016 at 11:27:28PM +0100, Andreas Schwab wrote:
> On powerpc -m32:
> 
> FAIL: gcc.dg/simd-7.c (test for excess errors)
> Excess errors:
> /daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-7.c:8:1: warning: GCC 
> vector returned by reference: non-standard ABI extension with no 
> compatibility guarantee
> /daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-7.c:7:1: warning: GCC 
> vector passed by reference: non-standard ABI extension with no compatibility 
> guarantee

Fixed thusly, committed as obvious:

2016-03-09  Jakub Jelinek  

PR middle-end/67278
* gcc.dg/simd-7.c: Add -w -Wno-psabi to dg-options.

--- gcc/testsuite/gcc.dg/simd-7.c   (revision 234078)
+++ gcc/testsuite/gcc.dg/simd-7.c   (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-options "-w -Wno-psabi" } */
 
 #if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8
 typedef long double a __attribute__((vector_size (16)));

Jakub


[PATCH] Fix PR67278, x86 target part

2016-03-02 Thread Richard Biener

The following fix from Uros properly (not) handles XFmode vectors in
type_natural_mode.

Bootstrapped and tested on x86_64-unknown-linux-gnu by Uros, applied.

Richard.

2016-03-02  Richard Biener  
Uros Bizjak  

PR target/67278
* config/i386/i386.c (type_natural_mode): Handle XFmode vectors.

* gcc.dg/simd-8.c: New testcase.

Index: gcc/config/i386/i386.c
===
--- gcc/config/i386/i386.c  (revision 233897)
+++ gcc/config/i386/i386.c  (working copy)
@@ -7794,6 +7794,10 @@ type_natural_mode (const_tree type, cons
{
  machine_mode innermode = TYPE_MODE (TREE_TYPE (type));
 
+ /* There are no XFmode vector modes.  */
+ if (innermode = XFmode)
+   return mode;
+
  if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
mode = MIN_MODE_VECTOR_FLOAT;
  else
Index: gcc/testsuite/gcc.dg/simd-8.c
===
--- gcc/testsuite/gcc.dg/simd-8.c   (revision 0)
+++ gcc/testsuite/gcc.dg/simd-8.c   (working copy)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8
+typedef long double a __attribute__((vector_size (32)));
+
+a __attribute__((noinline))
+sum (a first, a second)
+{
+return first + second;
+}
+
+a
+foo (a x, a y, a z)
+{
+  return sum (x, y) + z;
+}
+#else
+int main() {}
+#endif


Re: [PATCH] Fix PR67278, x86 target part

2016-03-02 Thread Uros Bizjak
On Wed, Mar 2, 2016 at 9:54 AM, Richard Biener  wrote:
>
> The following fix from Uros properly (not) handles XFmode vectors in
> type_natural_mode.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu by Uros, applied.
>
> Richard.
>
> 2016-03-02  Richard Biener  
> Uros Bizjak  
>
> PR target/67278
> * config/i386/i386.c (type_natural_mode): Handle XFmode vectors.
>
> * gcc.dg/simd-8.c: New testcase.
>
> Index: gcc/config/i386/i386.c
> ===
> --- gcc/config/i386/i386.c  (revision 233897)
> +++ gcc/config/i386/i386.c  (working copy)
> @@ -7794,6 +7794,10 @@ type_natural_mode (const_tree type, cons
> {
>   machine_mode innermode = TYPE_MODE (TREE_TYPE (type));
>
> + /* There are no XFmode vector modes.  */
> + if (innermode = XFmode)

No, not assignment "=" , but comparison "==" here!

Uros.


Re: [PATCH] Fix PR67278, x86 target part

2016-03-02 Thread Eric Botcazou
> Index: gcc/config/i386/i386.c
> ===
> --- gcc/config/i386/i386.c(revision 233897)
> +++ gcc/config/i386/i386.c(working copy)
> @@ -7794,6 +7794,10 @@ type_natural_mode (const_tree type, cons
>   {
> machine_mode innermode = TYPE_MODE (TREE_TYPE (type));
> 
> +   /* There are no XFmode vector modes.  */
> +   if (innermode = XFmode)
> + return mode;
> +
> if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
>   mode = MIN_MODE_VECTOR_FLOAT;
> else

You lost one of the '=' though.

-- 
Eric Botcazou


Re: [PATCH] Fix PR67278, x86 target part

2016-03-02 Thread Richard Biener
On Wed, 2 Mar 2016, Uros Bizjak wrote:

> On Wed, Mar 2, 2016 at 9:54 AM, Richard Biener  wrote:
> >
> > The following fix from Uros properly (not) handles XFmode vectors in
> > type_natural_mode.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu by Uros, applied.
> >
> > Richard.
> >
> > 2016-03-02  Richard Biener  
> > Uros Bizjak  
> >
> > PR target/67278
> > * config/i386/i386.c (type_natural_mode): Handle XFmode vectors.
> >
> > * gcc.dg/simd-8.c: New testcase.
> >
> > Index: gcc/config/i386/i386.c
> > ===
> > --- gcc/config/i386/i386.c  (revision 233897)
> > +++ gcc/config/i386/i386.c  (working copy)
> > @@ -7794,6 +7794,10 @@ type_natural_mode (const_tree type, cons
> > {
> >   machine_mode innermode = TYPE_MODE (TREE_TYPE (type));
> >
> > + /* There are no XFmode vector modes.  */
> > + if (innermode = XFmode)
> 
> No, not assignment "=" , but comparison "==" here!

Argh.

Fixed.

Richard.

2016-03-02  Richard Biener  

* config/i386/i386.c (type_natural_mode): Fix typo.

Index: gcc/config/i386/i386.c
===
--- gcc/config/i386/i386.c  (revision 233900)
+++ gcc/config/i386/i386.c  (working copy)
@@ -7795,7 +7795,7 @@ type_natural_mode (const_tree type, cons
  machine_mode innermode = TYPE_MODE (TREE_TYPE (type));
 
  /* There are no XFmode vector modes.  */
- if (innermode = XFmode)
+ if (innermode == XFmode)
return mode;
 
  if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)


Re: [PATCH] Fix PR67278, x86 target part

2016-03-08 Thread Andreas Schwab
Richard Biener  writes:

> Index: gcc/testsuite/gcc.dg/simd-8.c
> ===
> --- gcc/testsuite/gcc.dg/simd-8.c (revision 0)
> +++ gcc/testsuite/gcc.dg/simd-8.c (working copy)
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +
> +#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8
> +typedef long double a __attribute__((vector_size (32)));
> +
> +a __attribute__((noinline))
> +sum (a first, a second)
> +{
> +return first + second;
> +}
> +
> +a
> +foo (a x, a y, a z)
> +{
> +  return sum (x, y) + z;
> +}
> +#else
> +int main() {}
> +#endif

On powerpc:

FAIL: gcc.dg/simd-8.c (test for excess errors)
Excess errors:
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-8.c:8:1: warning: GCC vector 
returned by reference: non-standard ABI extension with no compatibility 
guarantee
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/simd-8.c:7:1: warning: GCC vector 
passed by reference: non-standard ABI extension with no compatibility guarantee

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."