public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/vrull/heads/slp-improvements)] Add testcases for #342
Date: Tue, 23 Jan 2024 20:58:23 +0000 (GMT)	[thread overview]
Message-ID: <20240123205823.8CE2F385802D@sourceware.org> (raw)

https://gcc.gnu.org/g:cdc6302234e4a971e352a6caaa0509ba594937e7

commit cdc6302234e4a971e352a6caaa0509ba594937e7
Author: Manolis Tsamis <manolis.tsamis@vrull.eu>
Date:   Fri Dec 1 12:45:12 2023 +0100

    Add testcases for #342

Diff:
---
 gcc/testsuite/gcc.target/aarch64/pr98138_1.c | 32 +++++++++++++++++++
 gcc/testsuite/gcc.target/aarch64/pr98138_2.c | 48 ++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/gcc/testsuite/gcc.target/aarch64/pr98138_1.c b/gcc/testsuite/gcc.target/aarch64/pr98138_1.c
new file mode 100644
index 00000000000..a9f7d4d6a99
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr98138_1.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-all" } */
+
+extern void test(unsigned int t[4][4]);
+
+void foo(unsigned char *p1, int i1, unsigned char *p2, int i2)
+{
+  unsigned int tmp[4][4];
+  unsigned int a0, a1, a2, a3;
+
+  for (int i = 0; i < 4; i++, p1 += i1, p2 += i2)
+    {
+      a0 = (p1[0] - p2[0]) + ((p1[4] - p2[4]) << 16);
+      a1 = (p1[1] - p2[1]) + ((p1[5] - p2[5]) << 16);
+      a2 = (p1[2] - p2[2]) + ((p1[6] - p2[6]) << 16);
+      a3 = (p1[3] - p2[3]) + ((p1[7] - p2[7]) << 16);
+
+      int t0 = a0 + a1;
+      int t1 = a0 - a1;
+      int t2 = a2 + a3;
+      int t3 = a2 - a3;
+
+      tmp[i][0] = t0 + t2;
+      tmp[i][2] = t0 - t2;
+      tmp[i][1] = t1 + t3;
+      tmp[i][3] = t1 - t3;
+    }
+
+  test(tmp);
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr98138_2.c b/gcc/testsuite/gcc.target/aarch64/pr98138_2.c
new file mode 100644
index 00000000000..7e85470a677
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr98138_2.c
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-all" } */
+
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+
+static inline
+uint32_t abs2 ( uint32_t a )
+{
+    uint32_t s = ((a>>15)&0x10001)*0xffff;
+    return (a+s)^s;
+}
+
+#define HADAMARD4(d0, d1, d2, d3, s0, s1, s2, s3) {\
+    int t0 = s0 + s1;\
+    int t1 = s0 - s1;\
+    int t2 = s2 + s3;\
+    int t3 = s2 - s3;\
+    d0 = t0 + t2;\
+    d2 = t0 - t2;\
+    d1 = t1 + t3;\
+    d3 = t1 - t3;\
+}
+
+int
+foo ( uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2 )
+{
+    uint32_t tmp[4][4];
+    uint32_t a0, a1, a2, a3;
+    int sum = 0;
+    for( int i = 0; i < 4; i++, pix1 += i_pix1, pix2 += i_pix2 )
+    {
+        a0 = (pix1[0] - pix2[0]) + ((pix1[4] - pix2[4]) << 16);
+        a1 = (pix1[1] - pix2[1]) + ((pix1[5] - pix2[5]) << 16);
+        a2 = (pix1[2] - pix2[2]) + ((pix1[6] - pix2[6]) << 16);
+        a3 = (pix1[3] - pix2[3]) + ((pix1[7] - pix2[7]) << 16);
+        HADAMARD4( tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], a0,a1,a2,a3 );
+    }
+    for( int i = 0; i < 4; i++ )
+    {
+        HADAMARD4( a0, a1, a2, a3, tmp[0][i], tmp[1][i], tmp[2][i], tmp[3][i] );
+        sum += abs2(a0) + abs2(a1) + abs2(a2) + abs2(a3);
+    }
+    return (((uint16_t)sum) + ((uint32_t)sum>>16)) >> 1;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 2 loops" "vect" } } */

             reply	other threads:[~2024-01-23 20:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 20:58 Philipp Tomsich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-17 19:15 Philipp Tomsich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240123205823.8CE2F385802D@sourceware.org \
    --to=ptomsich@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).