public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: rguenth@gcc.gnu.org
Subject: Fix endian issue in pr91656 testcases
Date: Sat, 28 Sep 2019 06:35:00 -0000	[thread overview]
Message-ID: <20190928063459.GA20197@bubble.grove.modra.org> (raw)

Tested on powerpc64le-linux and powerpc64-linux.  OK?

pr91656-3.c didn't really need to be changed since popcount doesn't
care which bits are set, but I figured it was better to make the test
set the low 16 bits of the 64-bit value in both big and litte endian.

	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.

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;
 }

-- 
Alan Modra
Australia Development Lab, IBM

             reply	other threads:[~2019-09-28  6:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-28  6:35 Alan Modra [this message]
2019-09-28  6:55 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190928063459.GA20197@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenth@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).