From 15333be70addf4eb750d82d5e298cd3ad33b711a Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 3 Jul 2018 19:33:28 +0200 Subject: [PATCH] re PR tree-optimization/85694 (Generation of vectorized AVG (Average) instruction) PR target/85694 * config/i386/sse.md (uavg3_ceil): New expander. (_uavg3): Simplify expander. testsuite/ChangeLog: PR target/85694 * gcc.target/i386/pr85694.c: New test. From-SVN: r262354 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/sse.md | 29 +++++++++++++++++++---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr85694.c | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr85694.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c550b6..7f5fa7b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-07-03 Uros Bizjak + + PR target/85694 + * config/i386/sse.md (uavg3_ceil): New expander. + (_uavg3): Simplify expander. + 2018-07-03 Richard Sandiford PR tree-optimization/85694 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 0420da8..d2722fdf 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -10764,6 +10764,24 @@ DONE; }) +(define_expand "uavg3_ceil" + [(set (match_operand:VI12_AVX2 0 "register_operand") + (truncate:VI12_AVX2 + (lshiftrt: + (plus: + (plus: + (zero_extend: + (match_operand:VI12_AVX2 1 "vector_operand")) + (zero_extend: + (match_operand:VI12_AVX2 2 "vector_operand"))) + (match_dup 3)) + (const_int 1))))] + "TARGET_SSE2" +{ + operands[3] = CONST1_RTX(mode); + ix86_fixup_binary_operands_no_copy (PLUS, mode, operands); +}) + (define_expand "usadv16qi" [(match_operand:V4SI 0 "register_operand") (match_operand:V16QI 1 "register_operand") @@ -14234,17 +14252,8 @@ (const_int 1))))] "TARGET_SSE2 && && " { - rtx tmp; - if () - tmp = operands[3]; - operands[3] = CONST1_RTX(mode); + operands[] = CONST1_RTX(mode); ix86_fixup_binary_operands_no_copy (PLUS, mode, operands); - - if () - { - operands[5] = operands[3]; - operands[3] = tmp; - } }) (define_insn "*_uavg3" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2afad58..d180610 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,11 @@ PR c++/86201 * g++.dg/diagnostic/pr86201.C: New test. +2018-07-03 Uros Bizjak + + PR target/85694 + * gcc.target/i386/pr85694.c: New test. + 2018-07-03 Richard Sandiford PR tree-optimization/85694 diff --git a/gcc/testsuite/gcc.target/i386/pr85694.c b/gcc/testsuite/gcc.target/i386/pr85694.c new file mode 100644 index 0000000..b730d23 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85694.c @@ -0,0 +1,18 @@ +/* { dg-do compile } +/* { dg-options "-msse2 -O2 -ftree-vectorize" } */ +/* { dg-final { scan-assembler "pavgb" } } */ +/* { dg-final { scan-assembler "pavgw" } } */ + +#define N 1024 + +#define TEST(TYPE) \ + unsigned TYPE a_##TYPE[N], b_##TYPE[N], c_##TYPE[N]; \ + void f_##TYPE (void) \ + { \ + int i; \ + for (i = 0; i < N; i++) \ + a_##TYPE[i] = (b_##TYPE[i] + c_##TYPE[i] + 1) >> 1; \ + } + +TEST(char); +TEST(short); -- 2.7.4