Re: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-09 Thread Jakub Jelinek
On Tue, Mar 08, 2016 at 11:16:28PM +0100, Andreas Schwab wrote:
> Marek Polacek  writes:
> 
> > diff --git gcc/testsuite/gcc.dg/pr70050.c gcc/testsuite/gcc.dg/pr70050.c
> > index e69de29..610456f 100644
> > --- gcc/testsuite/gcc.dg/pr70050.c
> > +++ gcc/testsuite/gcc.dg/pr70050.c
> > @@ -0,0 +1,11 @@
> > +/* PR middle-end/70025 */
> > +/* { dg-do compile } */
> > +/* { dg-options "-Wno-psabi" } */
> > +
> > +typedef int v8si __attribute__ ((vector_size (32)));
> > +
> > +v8si
> > +foo (v8si v)
> 
> On powerpc:
> 
> FAIL: gcc.dg/pr70050.c (test for excess errors)
> Excess errors:
> /daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/pr70050.c:9:1: warning: GCC 
> vector returned by reference: non-standard ABI extension with no 
> compatibility guarantee
> /daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/pr70050.c:8: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 target/67278
* gcc.dg/simd-8.c: Add -w -Wno-psabi to dg-options.

PR middle-end/70050
* gcc.dg/pr70050.c: Add -w to dg-options.  Fix up PR number
in testcase comment.

--- gcc/testsuite/gcc.dg/simd-8.c.jj2016-03-02 14:07:58.0 +0100
+++ gcc/testsuite/gcc.dg/simd-8.c   2016-03-09 10:11:15.726261498 +0100
@@ -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 (32)));
--- gcc/testsuite/gcc.dg/pr70050.c.jj   2016-03-03 15:28:40.0 +0100
+++ gcc/testsuite/gcc.dg/pr70050.c  2016-03-09 10:10:17.591060300 +0100
@@ -1,6 +1,6 @@
-/* PR middle-end/70025 */
+/* PR middle-end/70050 */
 /* { dg-do compile } */
-/* { dg-options "-Wno-psabi" } */
+/* { dg-options "-w -Wno-psabi" } */
 
 typedef int v8si __attribute__ ((vector_size (32)));
 


Jakub


Re: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-08 Thread Andreas Schwab
Marek Polacek  writes:

> diff --git gcc/testsuite/gcc.dg/pr70050.c gcc/testsuite/gcc.dg/pr70050.c
> index e69de29..610456f 100644
> --- gcc/testsuite/gcc.dg/pr70050.c
> +++ gcc/testsuite/gcc.dg/pr70050.c
> @@ -0,0 +1,11 @@
> +/* PR middle-end/70025 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wno-psabi" } */
> +
> +typedef int v8si __attribute__ ((vector_size (32)));
> +
> +v8si
> +foo (v8si v)

On powerpc:

FAIL: gcc.dg/pr70050.c (test for excess errors)
Excess errors:
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/pr70050.c:9:1: warning: GCC vector 
returned by reference: non-standard ABI extension with no compatibility 
guarantee
/daten/gcc/gcc-20160307/gcc/testsuite/gcc.dg/pr70050.c:8: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 ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-03 Thread Jakub Jelinek
On Thu, Mar 03, 2016 at 01:56:05PM +0100, Marc Glisse wrote:
> On Thu, 3 Mar 2016, Marek Polacek wrote:
> 
> >We crashed on the attached testcase because we were trying to apply the
> >X % -Y -> X % Y transformation even on vectors.  That doesn't go well with 
> >the
> >check for !TYPE_UNSIGNED.  So I think let's limit the pattern to only work on
> >integral types.
> 
> I certainly hope the problem is not with TYPE_UNSIGNED, I think there are
> many places where we use it on vectors. I would expect the issue to be with
> TYPE_MIN_VALUE a few lines below. Not that it changes anything to the fix...
> 
> (we can revisit that if vectors ever get VRP support)

And expr_not_equal_to would need to be tought to use that...

Jakub


Re: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-03 Thread Marek Polacek
On Thu, Mar 03, 2016 at 01:56:05PM +0100, Marc Glisse wrote:
> On Thu, 3 Mar 2016, Marek Polacek wrote:
> 
> >We crashed on the attached testcase because we were trying to apply the
> >X % -Y -> X % Y transformation even on vectors.  That doesn't go well with 
> >the
> >check for !TYPE_UNSIGNED.  So I think let's limit the pattern to only work on
> >integral types.
> 
> I certainly hope the problem is not with TYPE_UNSIGNED, I think there are
> many places where we use it on vectors. I would expect the issue to be with
> TYPE_MIN_VALUE a few lines below. Not that it changes anything to the fix...

Yes, as Jakub already pointed out.  My bad, sorry about that.

Marek


Re: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-03 Thread Marc Glisse

On Thu, 3 Mar 2016, Marek Polacek wrote:


We crashed on the attached testcase because we were trying to apply the
X % -Y -> X % Y transformation even on vectors.  That doesn't go well with the
check for !TYPE_UNSIGNED.  So I think let's limit the pattern to only work on
integral types.


I certainly hope the problem is not with TYPE_UNSIGNED, I think there are 
many places where we use it on vectors. I would expect the issue to be 
with TYPE_MIN_VALUE a few lines below. Not that it changes anything to the 
fix...


(we can revisit that if vectors ever get VRP support)


Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-03-03  Marek Polacek  

PR middle-end/70050
* match.pd (X % -Y): Add INTEGRAL_TYPE_P check.

* gcc.dg/pr70050.c: New test.

diff --git gcc/match.pd gcc/match.pd
index 5903782..112deb3 100644
--- gcc/match.pd
+++ gcc/match.pd
@@ -293,7 +293,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* X % -Y is the same as X % Y.  */
(simplify
 (trunc_mod @0 (convert? (negate @1)))
- (if (!TYPE_UNSIGNED (type)
+ (if (INTEGRAL_TYPE_P (type)
+  && !TYPE_UNSIGNED (type)
  && !TYPE_OVERFLOW_TRAPS (type)
  && tree_nop_conversion_p (type, TREE_TYPE (@1))
  /* Avoid this transformation if X might be INT_MIN or
diff --git gcc/testsuite/gcc.dg/pr70050.c gcc/testsuite/gcc.dg/pr70050.c
index e69de29..610456f 100644
--- gcc/testsuite/gcc.dg/pr70050.c
+++ gcc/testsuite/gcc.dg/pr70050.c
@@ -0,0 +1,11 @@
+/* PR middle-end/70025 */
+/* { dg-do compile } */
+/* { dg-options "-Wno-psabi" } */
+
+typedef int v8si __attribute__ ((vector_size (32)));
+
+v8si
+foo (v8si v)
+{
+  return v %= -v;
+}


--
Marc Glisse


Re: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050)

2016-03-03 Thread Jakub Jelinek
On Thu, Mar 03, 2016 at 12:04:31PM +0100, Marek Polacek wrote:
> We crashed on the attached testcase because we were trying to apply the
> X % -Y -> X % Y transformation even on vectors.  That doesn't go well with the
> check for !TYPE_UNSIGNED.  So I think let's limit the pattern to only work on
> integral types.

I think TYPE_UNSIGNED is fine, but TYPE_MIN_VALUE is not.

> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2016-03-03  Marek Polacek  
> 
>   PR middle-end/70050
>   * match.pd (X % -Y): Add INTEGRAL_TYPE_P check.
> 
>   * gcc.dg/pr70050.c: New test.

Ok, thanks.

Jakub