[COMMITTED] IBM Z: Fix vector intrinsics vec_double and vec_floate

Message ID 20210617091814.15698-1-mhillen@linux.ibm.com
State New
Headers show
Series
  • [COMMITTED] IBM Z: Fix vector intrinsics vec_double and vec_floate
Related show

Commit Message

David Malcolm via Gcc-patches June 17, 2021, 9:18 a.m.
Discussed offline with Andreas Krebbel.


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.
---
 gcc/config/s390/vecintrin.h                   |  4 ++--
 .../gcc.target/s390/zvector/vec-doublee.c     | 22 ++++++++++++++++++
 .../gcc.target/s390/zvector/vec-floate.c      | 23 +++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-doublee.c
 create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-floate.c

-- 
2.26.2

Patch

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]);
+}