From b164999002575eaca7f032c2374d2a04531be72f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 28 Sep 2019 16:42:14 +0930 Subject: [PATCH] Fix endian issue in pr91656 testcases PR testsuite/91676 PR rtl-optimization/91656 * gcc.dg/torture/pr91656-1.c: Correct for big and pdp endian. * gcc.dg/torture/pr91656-2.c: Likewise. * gcc.dg/torture/pr91656-3.c: Likewise. From-SVN: r276236 --- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/gcc.dg/torture/pr91656-1.c | 10 ++++++++++ gcc/testsuite/gcc.dg/torture/pr91656-2.c | 10 ++++++++++ gcc/testsuite/gcc.dg/torture/pr91656-3.c | 7 +++++++ 4 files changed, 35 insertions(+) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 163e38d5b6c..8fadb03e973 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-09-28 Alan Modra + + PR testsuite/91676 + PR rtl-optimization/91656 + * gcc.dg/torture/pr91656-1.c: Correct for big and pdp endian. + * gcc.dg/torture/pr91656-2.c: Likewise. + * gcc.dg/torture/pr91656-3.c: Likewise. + 2019-09-27 Jakub Jelinek PR c++/88203 diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-1.c b/gcc/testsuite/gcc.dg/torture/pr91656-1.c index 6c1e73c7f01..fae17de1112 100644 --- a/gcc/testsuite/gcc.dg/torture/pr91656-1.c +++ b/gcc/testsuite/gcc.dg/torture/pr91656-1.c @@ -6,7 +6,17 @@ int a, b, c, d, e; static __attribute__ ((__noipa__)) int foo (int i) { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ __builtin_memmove (&i, &e, 1); +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + __builtin_memmove ((char *) &i + sizeof (i) - 1, + (char *) &e + sizeof (e) - 1, 1); +#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ + __builtin_memmove ((char *) &i + sizeof (i) - 2, + (char *) &e + sizeof (e) - 2, 1); +#else +#error "endian unknown?" +#endif if (a > 0) i /= e; e /= 5; diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-2.c b/gcc/testsuite/gcc.dg/torture/pr91656-2.c index 90374becae0..29a619b280e 100644 --- a/gcc/testsuite/gcc.dg/torture/pr91656-2.c +++ b/gcc/testsuite/gcc.dg/torture/pr91656-2.c @@ -12,7 +12,17 @@ d (u16 g) { u64 f = __builtin_bswap64 (c); f = g == a; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ __builtin_memmove (&f, &e, 1); +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + __builtin_memmove ((char *) &f + sizeof (f) - 1, + (char *) &e + sizeof (e) - 1, 1); +#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ + __builtin_memmove ((char *) &f + sizeof (f) - 2, + (char *) &e + sizeof (e) - 2, 1); +#else +#error "endian unknown?" +#endif e >>= b; return a + f; } diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-3.c b/gcc/testsuite/gcc.dg/torture/pr91656-3.c index 8e65d24a21d..f84e51af4a4 100644 --- a/gcc/testsuite/gcc.dg/torture/pr91656-3.c +++ b/gcc/testsuite/gcc.dg/torture/pr91656-3.c @@ -10,7 +10,14 @@ int d (u16 e, u64 f) { b |= e; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ __builtin_memset (&f, e, 2); +#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ \ + || __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__) + __builtin_memset ((char *) &f + sizeof (f) - 2, e, 2); +#else +#error "endian unknown?" +#endif a = (u16) - e >= 2 ? : __builtin_popcountll (f); return a + c; } -- 2.30.2