testsuite: Fix some endianness bugs in p9 runnable tests.
authorDavid Edelsohn <dje.gcc@gmail.com>
Thu, 15 Oct 2020 18:12:52 +0000 (14:12 -0400)
committerDavid Edelsohn <dje.gcc@gmail.com>
Thu, 15 Oct 2020 19:25:40 +0000 (15:25 -0400)
This patch fixes some bugs in the powerpc testsuite for runnable tests
whose expected values were endian dependent.

gcc/testsuite/ChangeLog:

2020-10-15  David Edelsohn  <dje.gcc@gmail.com>

* gcc.target/powerpc/builtins-1-p9-runnable.c: Adjust for big endian.
* gcc.target/powerpc/builtins-7-p9-runnable.c: Same.

gcc/testsuite/gcc.target/powerpc/builtins-1-p9-runnable.c
gcc/testsuite/gcc.target/powerpc/builtins-7-p9-runnable.c

index 711e3d0eeaa0eb2f2685a8adf80d311d4af15c37..976654155b1a692e90fb29def2deb9e0bd8f2ee9 100644 (file)
@@ -16,8 +16,13 @@ int main() {
   vfb = (vector float){10.0, -2.0, 70.0, 999.0 };
 
   /* Expected results.  */
+#ifdef __BIG_ENDIAN__
+  vexpected = (vector unsigned short) { 0x4900, 0xc000, 0x5460, 0x63ce,
+                                       0x3666, 0x3e66, 0x4d00, 0x563e };
+#else
   vexpected = (vector unsigned short) { 0x3666, 0x3e66, 0x4d00, 0x563e,
-                                       0x4900, 0xc000, 0x5460, 0x63ce};
+                                       0x4900, 0xc000, 0x5460, 0x63ce };
+#endif
 
 /*
      vresult = vec_pack_to_short_fp32 (vfa, vfb);
@@ -44,7 +49,7 @@ int main() {
   for(i = 0; i< 8; i++) {
     if (vresult[i] != vexpected[i]) {
        printf("i=[%d] 0x%x != 0x%x \n",i,vresult[i],vexpected[i]);
-      abort();
+       abort();
     }
   }
 }
index 1333d01abaa6fcce6e9f7b79b17ca064e4d5d25e..fa4eb2db37e7835810659c8ddbc1332a67a7af92 100644 (file)
@@ -93,10 +93,17 @@ int main()
 
    vsi_arg = (vector signed int){0xA, 0xB, 0xC, 0xD};
 
+#ifdef __BIG_ENDIAN__
+   vec_uc_expected = (vector unsigned char){0, 0, 0, 0xB,
+                                           5, 6, 7, 8,
+                                           9, 10, 11, 12,
+                                           13, 14, 15, 16};
+#else
    vec_uc_expected = (vector unsigned char){0xC, 0, 0, 0,
                                            5, 6, 7, 8,
                                            9, 10, 11, 12,
                                            13, 14, 15, 16};
+#endif
    /* Test vec_insert4b() */
    /* Insert into char 0 location */
    vec_uc_result = vec_insert4b (vsi_arg, vec_uc_arg, 0);
@@ -112,10 +119,17 @@ int main()
       }
 
    /* insert into char 4 location */
+#ifdef __BIG_ENDIAN__
+   vec_uc_expected = (vector unsigned char){1, 2, 3, 4,
+                                           0, 0, 0, 3,
+                                           9, 10, 11, 12,
+                                           13, 14, 15, 16};
+#else
    vec_uc_expected = (vector unsigned char){1, 2, 3, 4,
                                            2, 0, 0, 0,
                                            9, 10, 11, 12,
                                            13, 14, 15, 16};
+#endif
    vui_arg = (vector unsigned int){0x4, 0x3, 0x2, 0x1};
 
    vec_uc_result = vec_insert4b (vui_arg, vec_uc_arg, 4);
@@ -132,12 +146,20 @@ int main()
 
    /* Test vec_extract4b() */
    /* Extract 4b, from char 0 location */
+#ifdef __BIG_ENDIAN__
+   vec_uc_arg = (vector unsigned char){0, 0, 0, 10,
+                                      0, 0, 0, 20,
+                                      0, 0, 0, 30,
+                                      0, 0, 0, 40};
+   vec_ull_expected = (vector unsigned long long){10, 0};
+#else
    vec_uc_arg = (vector unsigned char){10, 0, 0, 0,
                                       20, 0, 0, 0,
                                       30, 0, 0, 0,
                                       40, 0, 0, 0};
-
    vec_ull_expected = (vector unsigned long long){0, 10};
+#endif
+
    vec_ull_result = vec_extract4b(vec_uc_arg, 0);
 
    if (result_wrong_ull(vec_ull_expected, vec_ull_result))
@@ -151,12 +173,20 @@ int main()
       }
 
    /* Extract 4b, from char 12 location */
+#ifdef __BIG_ENDIAN__
+   vec_uc_arg = (vector unsigned char){0, 0, 0, 10,
+                                      0, 0, 0, 20,
+                                      0, 0, 0, 30,
+                                      0, 0, 0, 40};
+   vec_ull_expected = (vector unsigned long long){40, 0};
+#else
    vec_uc_arg = (vector unsigned char){10, 0, 0, 0,
                                       20, 0, 0, 0,
                                       30, 0, 0, 0,
                                       40, 0, 0, 0};
-
    vec_ull_expected = (vector unsigned long long){0, 40};
+#endif
+
    vec_ull_result = vec_extract4b(vec_uc_arg, 12);
 
    if (result_wrong_ull(vec_ull_expected, vec_ull_result))