From 56f1cb3fb94ab8f8335a45302bbc332634e65465 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 10 Apr 2018 14:37:36 +0200 Subject: [PATCH] re PR target/85177 (wrong code with -O -fno-tree-ccp -fno-tree-sra -mavx512f) PR target/85177 PR target/85255 * config/i386/sse.md (_vinsert_mask): Fix computation of the VEC_MERGE selector from mask. (_vinsert_1): Fix decoding of the VEC_MERGE selector into mask. * gcc.target/i386/avx512f-pr85177.c: New test. * gcc.target/i386/avx512f-pr85255.c: New test. From-SVN: r259269 --- gcc/ChangeLog | 10 +++++++ gcc/config/i386/sse.md | 18 +++++------ gcc/testsuite/ChangeLog | 7 +++++ .../gcc.target/i386/avx512f-pr85177.c | 30 +++++++++++++++++++ .../gcc.target/i386/avx512f-pr85255.c | 23 ++++++++++++++ 5 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-pr85177.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-pr85255.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 49589599269..c339cf975e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2018-04-10 Jakub Jelinek + + PR target/85177 + PR target/85255 + * config/i386/sse.md + (_vinsert_mask): Fix + computation of the VEC_MERGE selector from mask. + (_vinsert_1): + Fix decoding of the VEC_MERGE selector into mask. + 2018-04-10 Richard Sandiford PR tree-optimization/85286 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 34c007f8f43..caca42d9e0d 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -12627,11 +12627,11 @@ (match_operand: 5 "register_operand")] "TARGET_AVX512F" { - int mask,selector; + int mask, selector; mask = INTVAL (operands[3]); - selector = GET_MODE_UNIT_SIZE (mode) == 4 ? - 0xFFFF ^ (0xF000 >> mask * 4) - : 0xFF ^ (0xC0 >> mask * 2); + selector = (GET_MODE_UNIT_SIZE (mode) == 4 + ? 0xFFFF ^ (0x000F << mask * 4) + : 0xFF ^ (0x03 << mask * 2)); emit_insn (gen__vinsert_1_mask (operands[0], operands[1], operands[2], GEN_INT (selector), operands[4], operands[5])); @@ -12650,16 +12650,16 @@ int mask; int selector = INTVAL (operands[3]); - if (selector == 0xFFF || selector == 0x3F) + if (selector == (GET_MODE_UNIT_SIZE (mode) == 4 ? 0xFFF0 : 0xFC)) mask = 0; - else if ( selector == 0xF0FF || selector == 0xCF) + else if (selector == (GET_MODE_UNIT_SIZE (mode) == 4 ? 0xFF0F : 0xF3)) mask = 1; - else if ( selector == 0xFF0F || selector == 0xF3) + else if (selector == (GET_MODE_UNIT_SIZE (mode) == 4 ? 0xF0FF : 0xCF)) mask = 2; - else if ( selector == 0xFFF0 || selector == 0xFC) + else if (selector == (GET_MODE_UNIT_SIZE (mode) == 4 ? 0x0FFF : 0x3F)) mask = 3; else - gcc_unreachable (); + gcc_unreachable (); operands[3] = GEN_INT (mask); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3cfc12c3c91..1d68b755932 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-04-10 Jakub Jelinek + + PR target/85177 + PR target/85255 + * gcc.target/i386/avx512f-pr85177.c: New test. + * gcc.target/i386/avx512f-pr85255.c: New test. + 2018-04-10 Richard Sandiford PR tree-optimization/85286 diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr85177.c b/gcc/testsuite/gcc.target/i386/avx512f-pr85177.c new file mode 100644 index 00000000000..ab74927016c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr85177.c @@ -0,0 +1,30 @@ +/* PR target/85177 */ +/* { dg-do run { target { avx512f && int128 } } } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-sra -mavx512f -mno-avx512bw" } */ + +#include "avx512f-check.h" + +typedef short U __attribute__ ((vector_size (64))); +typedef __int128 V __attribute__ ((vector_size (64))); + +static inline __attribute__((always_inline)) U +foo (int i, U u) +{ + u[i & 1] = 1; + return u; +} + +__attribute__((noipa)) int +bar () +{ + V x = (V) foo (0, (U) { }); + for (unsigned i = 0; i < 4; i++) + if (x[i] != (i == 0)) __builtin_abort (); + return 0; +} + +static void +avx512f_test (void) +{ + bar (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr85255.c b/gcc/testsuite/gcc.target/i386/avx512f-pr85255.c new file mode 100644 index 00000000000..caaec14f583 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr85255.c @@ -0,0 +1,23 @@ +/* PR target/85255 */ +/* { dg-do run { target { avx512f } } } */ +/* { dg-options "-O2 -fno-tree-fre -mavx512f" } */ + +#include "avx512f-check.h" + +typedef short V __attribute__ ((vector_size (64))); + +V +foo (V v) +{ + v[v[1]] = 0; + return v; +} + +static void +avx512f_test (void) +{ + V v = foo ((V) { 1 }); + for (unsigned i = 0; i < 32; i++) + if (v[i] != 0) + __builtin_abort (); +} -- 2.30.2