[rs6000] Add missing builtin test cases

Message ID 1530137658.6530.21.camel@us.ibm.com
State New
Headers show
Series
  • [rs6000] Add missing builtin test cases
Related show

Commit Message

Carl Love June 27, 2018, 10:14 p.m.
GCC Maintainers:

The following patch adds missing test cases for
vec_extract_fp32_from_shortl(), vec_extract_fp32_from_shorth(), and
vec_extract().  

The patch has been run on:

  powerpc64le-unknown-linux-gnu (Power 8 LE)
  powerpc64le-unknown-linux-gnu (Power 9 LE)

without regressions.  

Please let me know if the following patch is acceptable.  Thanks.

                      Carl Love

-------------------------------------------------------------

gcc/testsuite/ChangeLog:

2018-06-27  Carl Love  <cel@us.ibm.com>

	* gcc.target/p9-extract-1.c: Add test case.
	* gcc.target/builtins-3-p9-runnable.c: Add test case to match
	name in ABI.
---
 .../gcc.target/powerpc/builtins-3-p9-runnable.c    | 42 ++++++++++++++++++++++
 gcc/testsuite/gcc.target/powerpc/p9-extract-1.c    |  8 +++++
 2 files changed, 50 insertions(+)

-- 
2.7.4

Comments

Segher Boessenkool June 28, 2018, 11:46 a.m. | #1
Hi!

On Wed, Jun 27, 2018 at 03:14:18PM -0700, Carl Love wrote:
> The following patch adds missing test cases for

> vec_extract_fp32_from_shortl(), vec_extract_fp32_from_shorth(), and

> vec_extract().  


This is fine for trunk.  Thank you!


Segher


> 2018-06-27  Carl Love  <cel@us.ibm.com>

> 

> 	* gcc.target/p9-extract-1.c: Add test case.

> 	* gcc.target/builtins-3-p9-runnable.c: Add test case to match

> 	name in ABI.

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3-p9-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-3-p9-runnable.c
index 3197a50..35a81a7 100644
--- a/gcc/testsuite/gcc.target/powerpc/builtins-3-p9-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/builtins-3-p9-runnable.c
@@ -30,6 +30,48 @@  int main() {
    printf ("                                0B011110100000000, 0B1011010000000000};\n\n");
 #endif
 
+   /* The ABI lists the builtins as:
+
+        vec_extract_fp32_from_shorth()
+        vec_extract_fp32_from_shortl()
+
+      GCC will also accept and map the builtin names
+
+        vec_extract_fp_from_shorth()
+        vec_extract_fp_from_shortl()
+
+      to the same builtins internally.  For completeness,
+      test both builtin function names.  */
+
+   vfexpt = (vector float){1.0, -2.0, 0.0, 8.5};
+   vfr = vec_extract_fp32_from_shorth(vusha);
+
+#ifdef DEBUG
+   printf ("vec_extract_fp32_from_shorth\n");
+   for (i=0; i<4; i++)
+     printf("result[%d] = %f; expected[%d] = %f\n",
+	    i, vfr[i], i, vfexpt[i]);
+#endif
+
+   for (i=0; i<4; i++) {
+      if (vfr[i] != vfexpt[i])
+         abort();
+   }
+
+   vfexpt = (vector float){1.5, 0.5, 1.25, -0.25};
+   vfr = vec_extract_fp32_from_shortl(vusha);
+
+#ifdef DEBUG
+   printf ("\nvec_extract_fp32_from_shortl\n");
+   for (i=0; i<4; i++)
+     printf("result[%d] = %f; expected[%d] = %f\n",
+	    i, vfr[i], i, vfexpt[i]);
+#endif
+
+    for (i=0; i<4; i++) {
+      if (vfr[i] != vfexpt[i])
+         abort();
+   }
    vfexpt = (vector float){1.0, -2.0, 0.0, 8.5};
    vfr = vec_extract_fp_from_shorth(vusha);
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-extract-1.c b/gcc/testsuite/gcc.target/powerpc/p9-extract-1.c
index ab9e766..203f5bf 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-extract-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-extract-1.c
@@ -122,6 +122,14 @@  extract_bool_int_0 (vector bool int a)
   return b;
 }
 
+unsigned short int
+extract_bool_short_int_0 (vector bool short int a)
+{
+  int c = 0;
+  unsigned short int b = vec_extract (a, c);
+  return b;
+}
+
 /* { dg-final { scan-assembler     "vextub\[lr\]x " } } */
 /* { dg-final { scan-assembler     "vextuh\[lr\]x " } } */
 /* { dg-final { scan-assembler     "vextuw\[lr\]x " } } */