diff mbox series

testsuite: Adjust powerpc test case pr83677.c for BE [PR108815]

Message ID caeae307-9630-68c3-6639-93f14394d9d8@linux.ibm.com
State New
Headers show
Series testsuite: Adjust powerpc test case pr83677.c for BE [PR108815] | expand

Commit Message

Kewen.Lin April 4, 2023, 5:22 a.m. UTC
Hi,

The test case gcc.target/powerpc/pr83677.c was written for
LE environment, this patch is to make it work on BE as well.

Tested on BE and LE well, I'm going to push this soon if no
objections.

BR,
Kewen
-----
	PR testsuite/108815

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr83677.c (v_expand_u8, v_expand_u16,
	v_load_deinterleave_f32, v_store_interleave_f32): Adjust some code by
	considering BE.
---
 gcc/testsuite/gcc.target/powerpc/pr83677.c | 30 +++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

--
2.39.1
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/pr83677.c b/gcc/testsuite/gcc.target/powerpc/pr83677.c
index c1a09687174..8b1caff3f98 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr83677.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr83677.c
@@ -9,14 +9,24 @@ 

 void v_expand_u8(vector unsigned char* a, vector unsigned short* b0, vector unsigned short* b1)
 {
+#if __LITTLE_ENDIAN__
   *b0 = (vector unsigned short)vec_mergeh(*a, vec_splats((unsigned char)0));
   *b1 = (vector unsigned short)vec_mergel(*a, vec_splats((unsigned char)0));
+#else
+  *b0 = (vector unsigned short)vec_mergeh(vec_splats((unsigned char)0), *a);
+  *b1 = (vector unsigned short)vec_mergel(vec_splats((unsigned char)0), *a);
+#endif
 }

 void v_expand_u16(vector unsigned short* a, vector unsigned int* b0, vector unsigned int* b1)
 {
+#if __LITTLE_ENDIAN__
     *b0 = (vector unsigned int)vec_mergeh(*a, vec_splats((unsigned short)0));
     *b1 = (vector unsigned int)vec_mergel(*a, vec_splats((unsigned short)0));
+#else
+    *b0 = (vector unsigned int)vec_mergeh(vec_splats((unsigned short)0), *a);
+    *b1 = (vector unsigned int)vec_mergel(vec_splats((unsigned short)0), *a);
+#endif
 }

 void v_load_deinterleave_u8(unsigned char *ptr, vector unsigned char* a, vector unsigned char* b, vector unsigned char* c)
@@ -44,13 +54,23 @@  void v_load_deinterleave_f32(float *ptr, vector float* a, vector float* b, vecto
     vector float v2 = vec_xl(16, ptr);
     vector float v3 = vec_xl(32, ptr);

+#if __LITTLE_ENDIAN__
+    vector float t1 = vec_sld(v3, v2, 8);
+    vector float t2 = vec_sld(v1, v3, 8);
+    vector float t3 = vec_sld(v2, v1, 8);
+#else
+    vector float t1 = vec_sld(v2, v3, 8);
+    vector float t2 = vec_sld(v3, v1, 8);
+    vector float t3 = vec_sld(v1, v2, 8);
+#endif
+
     static const vector unsigned char flp = {0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31};
-    *a = vec_perm(v1, vec_sld(v3, v2, 8), flp);
+    *a = vec_perm(v1, t1, flp);

     static const vector unsigned char flp2 = {28, 29, 30, 31, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19};
-    *b = vec_perm(v2, vec_sld(v1, v3, 8), flp2);
+    *b = vec_perm(v2, t2, flp2);

-    *c = vec_perm(vec_sld(v2, v1, 8), v3, flp);
+    *c = vec_perm(t3, v3, flp);
 }

 void v_store_interleave_f32(float *ptr, vector float a, vector float b, vector float c)
@@ -61,7 +81,11 @@  void v_store_interleave_f32(float *ptr, vector float a, vector float b, vector f
     vec_xst(vec_perm(a, hbc, ahbc),  0, ptr);

     vector float lab = vec_mergel(a, b);
+#if __LITTLE_ENDIAN__
     vec_xst(vec_sld(lab, hbc, 8), 16, ptr);
+#else
+    vec_xst(vec_sld(hbc, lab, 8), 16, ptr);
+#endif

     static const vector unsigned char clab = {8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 12, 13, 14, 15};
     vec_xst(vec_perm(c, lab, clab), 32, ptr);