From 1fc9aa543f41a1485187c96806950795a7966974 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 4 Jun 2018 15:49:55 +0200 Subject: [PATCH] re PR target/85832 ([AVX512] possible shorter code when comparing with vector of zeros) PR target/85832 PR target/86036 * config/i386/sse.md (_eq3_1): Use vptestnm rather than vptestm in (=Yc,v,C) variant. * gcc.target/i386/avx512f-pr85832.c: Expect vptestnm rather than vptestm. * gcc.target/i386/avx512vl-pr85832.c: Likewise. * gcc.target/i386/avx512vlbw-pr85832.c: Likewise. * gcc.target/i386/avx512bw-pr85832.c: Likewise. * gcc.target/i386/avx512bw-pr86036.c: New test. From-SVN: r261148 --- gcc/ChangeLog | 7 +++ gcc/config/i386/sse.md | 4 +- gcc/testsuite/ChangeLog | 11 +++++ .../gcc.target/i386/avx512bw-pr85832.c | 4 +- .../gcc.target/i386/avx512bw-pr86036.c | 48 +++++++++++++++++++ .../gcc.target/i386/avx512f-pr85832.c | 4 +- .../gcc.target/i386/avx512vl-pr85832.c | 4 +- .../gcc.target/i386/avx512vlbw-pr85832.c | 4 +- 8 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/avx512bw-pr86036.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83a7a4f9d90..eea029814cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-06-04 Jakub Jelinek + + PR target/85832 + PR target/86036 + * config/i386/sse.md (_eq3_1): + Use vptestnm rather than vptestm in (=Yc,v,C) variant. + 2018-06-04 Richard Biener * tree-cfgcleanup.c (cleanup_tree_cfg_1): Fold into... diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 082589433ec..2d4e495890d 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -11287,7 +11287,7 @@ "TARGET_AVX512BW && !(MEM_P (operands[1]) && MEM_P (operands[2]))" "@ vpcmpeq\t{%2, %1, %0|%0, %1, %2} - vptestm\t{%1, %1, %0|%0, %1, %1}" + vptestnm\t{%1, %1, %0|%0, %1, %1}" [(set_attr "type" "ssecmp") (set_attr "prefix_extra" "1") (set_attr "prefix" "evex") @@ -11302,7 +11302,7 @@ "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))" "@ vpcmpeq\t{%2, %1, %0|%0, %1, %2} - vptestm\t{%1, %1, %0|%0, %1, %1}" + vptestnm\t{%1, %1, %0|%0, %1, %1}" [(set_attr "type" "ssecmp") (set_attr "prefix_extra" "1") (set_attr "prefix" "evex") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6ec5c50b9e5..043a4f49495 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2018-06-04 Jakub Jelinek + + PR target/85832 + PR target/86036 + * gcc.target/i386/avx512f-pr85832.c: Expect vptestnm rather than + vptestm. + * gcc.target/i386/avx512vl-pr85832.c: Likewise. + * gcc.target/i386/avx512vlbw-pr85832.c: Likewise. + * gcc.target/i386/avx512bw-pr85832.c: Likewise. + * gcc.target/i386/avx512bw-pr86036.c: New test. + 2018-06-04 Richard Biener PR tree-optimization/86038 diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr85832.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr85832.c index 40e4a2a47e9..a406e0858ba 100644 --- a/gcc/testsuite/gcc.target/i386/avx512bw-pr85832.c +++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr85832.c @@ -1,8 +1,8 @@ /* PR target/85832 */ /* { dg-do compile } */ /* { dg-options "-O2 -mavx512bw -mno-avx512vl -masm=att" } */ -/* { dg-final { scan-assembler-times {\mvptestmb\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mvptestmw\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmb\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmw\M} 1 } } */ #include diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr86036.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr86036.c new file mode 100644 index 00000000000..47685e54f14 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr86036.c @@ -0,0 +1,48 @@ +/* PR target/86036 */ +/* { dg-do run } */ +/* { dg-options "-O -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#define AVX512BW +#include "avx512f-helper.h" + +typedef unsigned short V __attribute__ ((vector_size (64))); + +__attribute__((noipa)) V +foo (V a) +{ + return a >= 3; +} + +__attribute__((noipa)) V +bar (V a) +{ + return a != 0; +} + +__attribute__((noipa)) V +baz (V a) +{ + return a == 0; +} + +void +TEST (void) +{ + V a = (V) { 3, 17, 2, 0, 9, 1, 2, 3, 0, 0, 0, 3, 3, 3, 3, 3, + 9, 16387, 9, 3, 3, 0, 0, 3, 3, 3, 0, 0, 0, 0, 3, 3 }; + V b = foo (a); + V c = (V) { -1, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, 0, 0, 0, 0, -1, -1 }; + if (__builtin_memcmp (&b, &c, sizeof (b))) + abort (); + V d = bar (a); + V e = (V) { -1, -1, -1, 0, -1, -1, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, 0, 0, 0, 0, -1, -1 }; + if (__builtin_memcmp (&d, &e, sizeof (d))) + abort (); + V f = baz (a); + V g = ~e; + if (__builtin_memcmp (&f, &g, sizeof (f))) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr85832.c b/gcc/testsuite/gcc.target/i386/avx512f-pr85832.c index 98b71405ee0..a169776ec45 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-pr85832.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr85832.c @@ -1,8 +1,8 @@ /* PR target/85832 */ /* { dg-do compile } */ /* { dg-options "-O2 -mavx512f -mno-avx512vl -mno-avx512bw -masm=att" } */ -/* { dg-final { scan-assembler-times {\mvptestmd\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mvptestmq\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmd\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmq\M} 1 } } */ #include diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-pr85832.c b/gcc/testsuite/gcc.target/i386/avx512vl-pr85832.c index 6eb7178124b..09ed8936c21 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-pr85832.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-pr85832.c @@ -1,8 +1,8 @@ /* PR target/85832 */ /* { dg-do compile } */ /* { dg-options "-O2 -mavx512vl -mno-avx512bw -masm=att" } */ -/* { dg-final { scan-assembler-times {\mvptestmd\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mvptestmq\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmd\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmq\M} 2 } } */ #include diff --git a/gcc/testsuite/gcc.target/i386/avx512vlbw-pr85832.c b/gcc/testsuite/gcc.target/i386/avx512vlbw-pr85832.c index 6fbdf5aec71..ee93e0ddd59 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vlbw-pr85832.c +++ b/gcc/testsuite/gcc.target/i386/avx512vlbw-pr85832.c @@ -1,8 +1,8 @@ /* PR target/85832 */ /* { dg-do compile } */ /* { dg-options "-O2 -mavx512vl -mavx512bw -masm=att" } */ -/* { dg-final { scan-assembler-times {\mvptestmb\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mvptestmw\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmb\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mvptestnmw\M} 2 } } */ #include -- 2.30.2