From c54eb7f40ce09bc22aca2aea7cdde6e286249ada Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 21 May 2019 18:00:37 +0200 Subject: [PATCH] sse.md (VF1_AVX2): New mode iterator. * config/i386/sse.md (VF1_AVX2): New mode iterator. (signbit2): New expander testsuite/ChangeLog: * gcc.target/i386/vect-signbitf.c: New test. From-SVN: r271473 --- gcc/ChangeLog | 5 ++++ gcc/config/i386/sse.md | 12 ++++++++ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.target/i386/vect-signbitf.c | 30 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/vect-signbitf.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 23b9b117445..0651fbabed2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-05-21 Uroš Bizjak + + * config/i386/sse.md (VF1_AVX2): New mode iterator. + (signbit2): New expander + 2019-05-21 James Clarke PR bootstrap/87338 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 677e7023eb2..7e7b3417cfc 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -279,6 +279,9 @@ (define_mode_iterator VF1 [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF]) +(define_mode_iterator VF1_AVX2 + [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX2") V4SF]) + ;; 128- and 256-bit SF vector modes (define_mode_iterator VF1_128_256 [(V8SF "TARGET_AVX") V4SF]) @@ -3523,6 +3526,15 @@ operands[4] = gen_reg_rtx (mode); }) +(define_expand "signbit2" + [(set (match_operand: 0 "register_operand") + (lshiftrt: + (subreg: + (match_operand:VF1_AVX2 1 "register_operand") 0) + (match_dup 2)))] + "TARGET_SSE2" + "operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (mode)-1);") + ;; Also define scalar versions. These are used for abs, neg, and ;; conditional move. Using subregs into vector modes causes register ;; allocation lossage. These patterns do not allow memory operands diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bdc58ba14e4..6206ef52c4a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-05-21 Uroš Bizjak + + * gcc.target/i386/vect-signbitf.c: New test. + 2019-05-21 Nathan Sidwell * g++.dg/lookup/using53.C: Adjust diagnostic. diff --git a/gcc/testsuite/gcc.target/i386/vect-signbitf.c b/gcc/testsuite/gcc.target/i386/vect-signbitf.c new file mode 100644 index 00000000000..b3ef1062c83 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-signbitf.c @@ -0,0 +1,30 @@ +/* { dg-do run { target sse2_runtime } } */ +/* { dg-options "-O2 -msse2 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */ + +extern void abort (); + +#define N 1024 +float a[N] = {0.0f, -0.0f, 1.0f, -1.0f, + -2.0f, 3.0f, -5.0f, -8.0f, + 13.0f, 21.0f, -25.0f, 33.0f}; +int r[N]; + +int +main (void) +{ + int i; + + for (i = 0; i < N; i++) + r[i] = __builtin_signbitf (a[i]); + + /* check results: */ + for (i = 0; i < N; i++) + if (__builtin_signbit (a[i]) && !r[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-assembler-not "-2147483648" } } */ +/* { dg-final { scan-assembler "psrld" } } */ -- 2.30.2