From: Jakub Jelinek Date: Wed, 10 Dec 2014 19:59:57 +0000 (+0100) Subject: re PR target/64252 (expand_vec_perm_pblendv caused miscompilation) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ec5dd98f08168f9230127008432286b8dc4f035;p=gcc.git re PR target/64252 (expand_vec_perm_pblendv caused miscompilation) PR target/64252 * config/i386/i386.c (expand_vec_perm_pblendv): If not testing_p, set dcopy.target to a new pseudo. * gcc.dg/vect/pr64252.c: New test. * gcc.dg/pr64252.c: New test. * gcc.target/i386/avx2-pr64252.c: New test. Co-Authored-By: Evgeny Stupachenko From-SVN: r218602 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c4be729733..cce54061e4d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-12-10 Jakub Jelinek + Evgeny Stupachenko + + PR target/64252 + * config/i386/i386.c (expand_vec_perm_pblendv): If not testing_p, + set dcopy.target to a new pseudo. + 2014-12-10 Segher Boessenkool * config/rs6000/rs6000.md (*add3): Remove condition. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 9fe69cc61f7..fd2a6ed021f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -47554,6 +47554,8 @@ expand_vec_perm_pblendv (struct expand_vec_perm_d *d) dcopy.op0 = dcopy.op1 = d->op1; else dcopy.op0 = dcopy.op1 = d->op0; + if (!d->testing_p) + dcopy.target = gen_reg_rtx (vmode); dcopy.one_operand_p = true; for (i = 0; i < nelt; ++i) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5932dd060f4..0f204acd684 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2014-12-10 Jakub Jelinek + Evgeny Stupachenko + + PR target/64252 + * gcc.dg/vect/pr64252.c: New test. + * gcc.dg/pr64252.c: New test. + * gcc.target/i386/avx2-pr64252.c: New test. + 2014-12-10 Ilya Enkovich * gcc.dg/lto/chkp-privatize_0.c: Remove unneeded selector diff --git a/gcc/testsuite/gcc.dg/pr64252.c b/gcc/testsuite/gcc.dg/pr64252.c new file mode 100644 index 00000000000..71f9c7812a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr64252.c @@ -0,0 +1,30 @@ +/* PR target/64252 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +typedef unsigned int V __attribute__((vector_size (32))); + +__attribute__((noinline, noclone)) void +foo (V *a, V *b, V *c, V *d, V *e) +{ + V t = __builtin_shuffle (*a, *b, *c); + V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, (V) { 0, 1, 8, 3, 4, 5, 9, 7 }); + v = v + *d; + *e = v; +} + +int +main () +{ + V a, b, c, d, e; + int i; + a = (V) { 1, 2, 3, 4, 5, 6, 7, 8 }; + b = (V) { 9, 10, 11, 12, 13, 14, 15, 16 }; + c = (V) { 1, 3, 5, 7, 9, 11, 13, 15 }; + d = (V) { 0, 0, 0, 0, 0, 0, 0, 0 }; + foo (&a, &b, &c, &d, &e); + for (i = 0; i < 8; i++) + if (e[i] != ((i == 2 || i == 6) ? ~0U : 2 + 2 * i)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr64252.c b/gcc/testsuite/gcc.dg/vect/pr64252.c new file mode 100644 index 00000000000..19bdf3990d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr64252.c @@ -0,0 +1,66 @@ +/* PR target/64252 */ +/* Test correctness of size 3 store groups permutation. */ +/* { dg-do run } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#define N 50 + +enum num3 +{ + a, b, c +}; + +struct flags +{ + enum num3 f; + unsigned int c; + unsigned int p; +}; + +struct flagsN +{ + struct flags a[N]; +}; + +void +bar (int n, struct flagsN *ff) +{ + struct flagsN *fc; + for (fc = ff + 1; fc < (ff + n); fc++) + { + int i; + for (i = 0; i < N; ++i) + { + ff->a[i].f = 0; + ff->a[i].c = i; + ff->a[i].p = -1; + } + for (i = 0; i < n; i++) + { + int j; + for (j = 0; j < N - n; ++j) + { + fc->a[i + j].f = 0; + fc->a[i + j].c = j + i; + fc->a[i + j].p = -1; + } + } + } +} + +struct flagsN q[2]; + +int main() +{ + int i; + check_vect (); + bar(2, q); + for (i = 0; i < N; i++) + if (q[0].a[i].f != 0 || q[0].a[i].c != i || q[0].a[i].p != -1) + abort (); + return 0; +} +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-pr64252.c b/gcc/testsuite/gcc.target/i386/avx2-pr64252.c new file mode 100644 index 00000000000..b368a541673 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-pr64252.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx2" } */ +/* { dg-require-effective-target avx2 } */ + +#include "avx2-check.h" + +#define main() do_main () + +#include "../../gcc.dg/pr64252.c" + +static void +avx2_test (void) +{ + do_main (); +}