* [PATCH] Fix PR91069
@ 2019-07-03 10:49 Richard Biener
2019-07-04 6:50 ` Jakub Jelinek
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2019-07-03 10:49 UTC (permalink / raw)
To: gcc-patches
Late FRE uncovered a bug in vec-perm folding.
Boostrap / regtest running on x86_64-unknown-linux-gnu.
Richard.
2019-07-03 Richard Biener <rguenther@suse.de>
PR middle-end/91069
* match.pd (vec_perm -> bit_insert): Fix element read from
first vector.
* gcc.dg/pr91069.c: New testcase.
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 272958)
+++ gcc/match.pd (working copy)
@@ -5520,7 +5520,7 @@ (define_operator_list COND_TERNARY
first vector we only can insert the first elt from
the first vector. */
at = 0;
- if ((ins = fold_read_from_vector (cop0, 0)))
+ if ((ins = fold_read_from_vector (cop0, sel[0])))
op0 = op1;
}
else
Index: gcc/testsuite/gcc.dg/pr91069.c
===================================================================
--- gcc/testsuite/gcc.dg/pr91069.c (nonexistent)
+++ gcc/testsuite/gcc.dg/pr91069.c (working copy)
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+typedef double v2df __attribute__((vector_size(16)));
+typedef long v2di __attribute__((vector_size(16)));
+
+void foo (v2df *res, v2df *src)
+{
+ v2df x = *src;
+ *res = __builtin_shuffle ((v2df) { 1.0, 0.0 }, x, (v2di) { 1, 3 });
+}
+
+int main()
+{
+ v2df x = (v2df) { 0.0, 2.0 };
+ foo (&x, &x);
+ if (x[0] != 0.0 || x[1] != 2.0)
+ __builtin_abort ();
+ return 0;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PR91069
2019-07-03 10:49 [PATCH] Fix PR91069 Richard Biener
@ 2019-07-04 6:50 ` Jakub Jelinek
2019-07-04 7:34 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2019-07-04 6:50 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Wed, Jul 03, 2019 at 12:49:34PM +0200, Richard Biener wrote:
> 2019-07-03 Richard Biener <rguenther@suse.de>
>
> PR middle-end/91069
> * match.pd (vec_perm -> bit_insert): Fix element read from
> first vector.
>
> * gcc.dg/pr91069.c: New testcase.
I've noticed the testcase FAILs on ia32, the problem is that long is
32-bit and so v2di type isn't v2di we are expecting, but v4si and mismatches
the v2df in number of elements and element precision.
Fixed thusly, regtested on x86_64-linux and i686-linux, committed to trunk.
Note, still not truly portable, if double and long long have different
sizes on some target, this will still fail.
2019-07-04 Jakub Jelinek <jakub@redhat.com>
PR middle-end/91069
* gcc.dg/pr91069.c (v2df): Use 2 * sizeof (double) instead of
hardcoded 16 for better portability.
(v2di): Change from long vector to long long vector. Use
2 * sizeof (long long) instead of hardcoded 16.
--- gcc/testsuite/gcc.dg/pr91069.c.jj 2019-07-04 00:18:31.510099301 +0200
+++ gcc/testsuite/gcc.dg/pr91069.c 2019-07-04 07:08:24.944046933 +0200
@@ -1,8 +1,8 @@
/* { dg-do run } */
/* { dg-options "-std=gnu11" } */
-typedef double v2df __attribute__((vector_size(16)));
-typedef long v2di __attribute__((vector_size(16)));
+typedef double v2df __attribute__((vector_size(2 * sizeof (double))));
+typedef long long v2di __attribute__((vector_size(2 * sizeof (long long))));
void foo (v2df *res, v2df *src)
{
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PR91069
2019-07-04 6:50 ` Jakub Jelinek
@ 2019-07-04 7:34 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2019-07-04 7:34 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Thu, 4 Jul 2019, Jakub Jelinek wrote:
> On Wed, Jul 03, 2019 at 12:49:34PM +0200, Richard Biener wrote:
> > 2019-07-03 Richard Biener <rguenther@suse.de>
> >
> > PR middle-end/91069
> > * match.pd (vec_perm -> bit_insert): Fix element read from
> > first vector.
> >
> > * gcc.dg/pr91069.c: New testcase.
>
> I've noticed the testcase FAILs on ia32, the problem is that long is
> 32-bit and so v2di type isn't v2di we are expecting, but v4si and mismatches
> the v2df in number of elements and element precision.
>
> Fixed thusly, regtested on x86_64-linux and i686-linux, committed to trunk.
>
> Note, still not truly portable, if double and long long have different
> sizes on some target, this will still fail.
Hmm, yeah. I guess some #if on __SIZEOF_LONG_LONG__ != __SIZEOF_DOUBLE__
might do the trick. OTOH it would be nice if we'd not need to
spell out the vector type for constant shuffles but have the FE
autodetect them, thus make
__builtin_shuffle ((v2df) { 1.0, 0.0 }, x, { 1, 3 })
work magically.
Richard.
> 2019-07-04 Jakub Jelinek <jakub@redhat.com>
>
> PR middle-end/91069
> * gcc.dg/pr91069.c (v2df): Use 2 * sizeof (double) instead of
> hardcoded 16 for better portability.
> (v2di): Change from long vector to long long vector. Use
> 2 * sizeof (long long) instead of hardcoded 16.
>
> --- gcc/testsuite/gcc.dg/pr91069.c.jj 2019-07-04 00:18:31.510099301 +0200
> +++ gcc/testsuite/gcc.dg/pr91069.c 2019-07-04 07:08:24.944046933 +0200
> @@ -1,8 +1,8 @@
> /* { dg-do run } */
> /* { dg-options "-std=gnu11" } */
>
> -typedef double v2df __attribute__((vector_size(16)));
> -typedef long v2di __attribute__((vector_size(16)));
> +typedef double v2df __attribute__((vector_size(2 * sizeof (double))));
> +typedef long long v2di __attribute__((vector_size(2 * sizeof (long long))));
>
> void foo (v2df *res, v2df *src)
> {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-04 7:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 10:49 [PATCH] Fix PR91069 Richard Biener
2019-07-04 6:50 ` Jakub Jelinek
2019-07-04 7:34 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).