public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marius Hillenbrand <mhillen@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1559] IBM Z: Fix vector intrinsics vec_double and vec_floate
Date: Thu, 17 Jun 2021 09:14:57 +0000 (GMT)	[thread overview]
Message-ID: <20210617091457.939B7385BF99@sourceware.org> (raw)

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

commit r12-1559-ga4fc63e0c3c6c7b895225c883137d152743be7fc
Author: Marius Hillenbrand <mhillen@linux.ibm.com>
Date:   Wed Jun 16 18:26:48 2021 +0200

    IBM Z: Fix vector intrinsics vec_double and vec_floate
    
    Fix the mapping of vec_double and vec_floate to builtins.
    
    gcc/ChangeLog:
    
            PR target/100871
            * config/s390/vecintrin.h (vec_doublee): Fix to use
              __builtin_s390_vflls.
            (vec_floate): Fix to use __builtin_s390_vflrd.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/s390/zvector/vec-doublee.c: New test.
            * gcc.target/s390/zvector/vec-floate.c: New test.

Diff:
---
 gcc/config/s390/vecintrin.h                        |  4 ++--
 .../gcc.target/s390/zvector/vec-doublee.c          | 22 +++++++++++++++++++++
 gcc/testsuite/gcc.target/s390/zvector/vec-floate.c | 23 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/gcc/config/s390/vecintrin.h b/gcc/config/s390/vecintrin.h
index 6bd26f8a240..9a3f7c347ac 100644
--- a/gcc/config/s390/vecintrin.h
+++ b/gcc/config/s390/vecintrin.h
@@ -109,8 +109,8 @@ __lcbb(const void *ptr, int bndry)
 #define vec_rint(X)   __builtin_s390_vfi((X), 0, 0)
 #define vec_roundc(X) __builtin_s390_vfi((X), 4, 0)
 #define vec_round(X)  __builtin_s390_vfi((X), 4, 4)
-#define vec_doublee(X) __builtin_s390_vfll((X))
-#define vec_floate(X) __builtin_s390_vflr((X), 0, 0)
+#define vec_doublee(X) __builtin_s390_vflls((X))
+#define vec_floate(X) __builtin_s390_vflrd((X), 0, 0)
 #define vec_load_len_r(X,L)				\
   (__vector unsigned char)__builtin_s390_vlrlr((L),(X))
 #define vec_store_len_r(X,Y,L) \
diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-doublee.c b/gcc/testsuite/gcc.target/s390/zvector/vec-doublee.c
new file mode 100644
index 00000000000..11610f225e5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/zvector/vec-doublee.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z14 -mzarch -mzvector --save-temps" } */
+/* { dg-do run { target { s390_z14_hw } } } */
+
+/*
+ * The vector intrinsic vec_doublee(a) converts the even-indexed
+ * single-precision numbers in a vector to double precision.
+ */
+#include <assert.h>
+#include <vecintrin.h>
+
+int
+main (void)
+{
+    vector float in = { 1.0, 2.0, 3.0, 4.0 };
+
+    vector double result = vec_doublee(in);
+    /* { dg-final { scan-assembler-times {\n\tvldeb} 1 } } */
+
+    assert(result[0] == (double)in[0]);
+    assert(result[1] == (double)in[2]);
+}
diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-floate.c b/gcc/testsuite/gcc.target/s390/zvector/vec-floate.c
new file mode 100644
index 00000000000..0b9cbe3d89e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/zvector/vec-floate.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z14 -mzarch -mzvector --save-temps" } */
+/* { dg-do run { target { s390_z14_hw } } } */
+
+/*
+ * The vector intrinsic vec_floate(a) rounds a vector of double-precision
+ * numbers to single-precision. The results are stored in the even-numbered
+ * target elements.
+ */
+#include <assert.h>
+#include <vecintrin.h>
+
+int
+main (void)
+{
+    vector double in = { 1.0, 2.0 };
+
+    vector float result = vec_floate(in);
+    /* { dg-final { scan-assembler-times {\n\tvledb} 1 } } */
+
+    assert(result[0] == (float)in[0]);
+    assert(result[2] == (float)in[1]);
+}


                 reply	other threads:[~2021-06-17  9:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210617091457.939B7385BF99@sourceware.org \
    --to=mhillen@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).