From b7beab8282a877da06713bf38f9440ccc82f10b9 Mon Sep 17 00:00:00 2001 From: David Edelsohn Date: Thu, 15 Oct 2020 14:12:52 -0400 Subject: [PATCH] testsuite: Fix some endianness bugs in p9 runnable tests. 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 * gcc.target/powerpc/builtins-1-p9-runnable.c: Adjust for big endian. * gcc.target/powerpc/builtins-7-p9-runnable.c: Same. --- .../powerpc/builtins-1-p9-runnable.c | 9 +++-- .../powerpc/builtins-7-p9-runnable.c | 34 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-1-p9-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-1-p9-runnable.c index 711e3d0eeaa..976654155b1 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-1-p9-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-1-p9-runnable.c @@ -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(); } } } diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-7-p9-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-7-p9-runnable.c index 1333d01abaa..fa4eb2db37e 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-7-p9-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-7-p9-runnable.c @@ -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)) -- 2.30.2