re PR tree-optimization/85693 (Generation of SAD (Sum of Absolute Difference) instruc...
authorUros Bizjak <ubizjak@gmail.com>
Thu, 1 Aug 2019 18:07:19 +0000 (20:07 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 1 Aug 2019 18:07:19 +0000 (20:07 +0200)
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
gcc/config/i386/mmx.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr85693-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85693.c

index dc06ef4694349e46c73d164a1364a34c4b81a24a..8efcffaef8a89f85c4b1d15867cade6a15b0a320 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-01  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR target/85693
+       * config/i386/mmx.md (usadv8qi): New expander.
+
 2019-08-01  Matthew Beliveau  <mbelivea@redhat.com>
 
        PR c++/90590
index 67bcf5b240db61560080351a1f6ab08d6238178a..3bbf5e07dcbe24902e99e7a62f1d581c3a2a9626 100644 (file)
   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")]
index 6b363ac3e0be62d5d710dbe1f31db5e222129ba2..0b4334a8cbdfc82583d4414678f2df183a232deb 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-01  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR target/85693
+       * gcc.target/i386/pr85693-1.c: New test.
+
 2019-08-01  Matthew Beliveau  <mbelivea@redhat.com>
 
        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 (file)
index 0000000..b2bf58d
--- /dev/null
@@ -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" } } */
index 214a739fcbd6956b360c5e8e42e57b058b2dd71b..9843ea527cb69e7bc89e53b6950f3262b9fa65db 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do compile }
+/* { dg-do compile } */
 /* { dg-options "-msse2 -O2 -ftree-vectorize" } */
 
 #define N 1024