From 45230a4019ed9f03ea63b3c25c8e4a9b9897dc98 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 1 Aug 2019 20:07:19 +0200 Subject: [PATCH] re PR tree-optimization/85693 (Generation of SAD (Sum of Absolute Difference) instruction) PR target/85693 * config/i386/mmx.md (usadv8qi): New expander. testsuite/ChangeLog: PR target/85693 * gcc.target/i386/pr85693-1.c: New test. From-SVN: r273981 --- gcc/ChangeLog | 5 +++++ gcc/config/i386/mmx.md | 15 +++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr85693-1.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr85693.c | 2 +- 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr85693-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc06ef46943..8efcffaef8a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-08-01 Uroš Bizjak + + PR target/85693 + * config/i386/mmx.md (usadv8qi): New expander. + 2019-08-01 Matthew Beliveau PR c++/90590 diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index 67bcf5b240d..3bbf5e07dcb 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -1970,6 +1970,21 @@ DONE; }) +(define_expand "usadv8qi" + [(match_operand:V2SI 0 "register_operand") + (match_operand:V8QI 1 "register_operand") + (match_operand:V8QI 2 "vector_operand") + (match_operand:V2SI 3 "vector_operand")] + "TARGET_MMX_WITH_SSE" +{ + rtx t1 = gen_reg_rtx (V1DImode); + rtx t2 = gen_reg_rtx (V2SImode); + emit_insn (gen_mmx_psadbw (t1, operands[1], operands[2])); + convert_move (t2, t1, 0); + emit_insn (gen_addv2si3 (operands[0], t2, operands[3])); + DONE; +}) + (define_insn_and_split "mmx_pmovmskb" [(set (match_operand:SI 0 "register_operand" "=r,r") (unspec:SI [(match_operand:V8QI 1 "register_operand" "y,x")] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b363ac3e0b..0b4334a8cbd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-01 Uroš Bizjak + + PR target/85693 + * gcc.target/i386/pr85693-1.c: New test. + 2019-08-01 Matthew Beliveau PR c++/90590 diff --git a/gcc/testsuite/gcc.target/i386/pr85693-1.c b/gcc/testsuite/gcc.target/i386/pr85693-1.c new file mode 100644 index 00000000000..b2bf58d9e29 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85693-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-msse2 -O2 -ftree-vectorize" } */ + +#define N 8 + +int abs (int); + +unsigned char pix1[N], pix2[N]; + +int foo (void) +{ + int i_sum = 0; + int i; + + for (i = 0; i < N; i++) + i_sum += abs (pix1[i] - pix2[i]); + + return i_sum; +} + +/* { dg-final { scan-assembler "psadbw" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr85693.c b/gcc/testsuite/gcc.target/i386/pr85693.c index 214a739fcbd..9843ea527cb 100644 --- a/gcc/testsuite/gcc.target/i386/pr85693.c +++ b/gcc/testsuite/gcc.target/i386/pr85693.c @@ -1,4 +1,4 @@ -/* { dg-do compile } +/* { dg-do compile } */ /* { dg-options "-msse2 -O2 -ftree-vectorize" } */ #define N 1024 -- 2.30.2