public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@sourceware.org, Peter Bergner <bergner@vnet.ibm.com>
Subject: Re: [RS6000] rotate and mask constants
Date: Tue, 15 Sep 2020 16:46:08 +0930	[thread overview]
Message-ID: <20200915071608.GJ5452@bubble.grove.modra.org> (raw)
In-Reply-To: <20200915011946.3395-9-amodra@gmail.com>

On Tue, Sep 15, 2020 at 10:49:46AM +0930, Alan Modra wrote:
> Implement more two insn constants.

And tests.  rot_cst1 checks the values generated, rot_cst2 checks
instruction count.

	* gcc.target/powerpc/rot_cst.h,
	* gcc.target/powerpc/rot_cst1.c,
	* gcc.target/powerpc/rot_cst2.c: New tests.

diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst.h b/gcc/testsuite/gcc.target/powerpc/rot_cst.h
new file mode 100644
index 00000000000..0d100d61233
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rot_cst.h
@@ -0,0 +1,269 @@
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c1 (void)
+{
+  return 0xc000000000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c2 (void)
+{
+  return 0xc00000000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c3 (void)
+{
+  return 0xc0000000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c4 (void)
+{
+  return 0xc000000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c5 (void)
+{
+  return 0xc00000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c6 (void)
+{
+  return 0xc0000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c7 (void)
+{
+  return 0xc000000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c8 (void)
+{
+  return 0xc00000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c9 (void)
+{
+  return 0xc0000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c10 (void)
+{
+  return 0xc000000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c11 (void)
+{
+  return 0xc00000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c12 (void)
+{
+  return 0xc0000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c13 (void)
+{
+  return 0xc000ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c14 (void)
+{
+  return 0xc00ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c15 (void)
+{
+  return 0xc0ULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+c16 (void)
+{
+  return 0xcULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b1 (void)
+{
+  return 0xbfffffffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b2 (void)
+{
+  return 0xbffffffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b3 (void)
+{
+  return 0xbfffffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b4 (void)
+{
+  return 0xbffffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b5 (void)
+{
+  return 0xbfffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b6 (void)
+{
+  return 0xbffffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b7 (void)
+{
+  return 0xbfffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b8 (void)
+{
+  return 0xbffffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b9 (void)
+{
+  return 0xbfffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b10 (void)
+{
+  return 0xbffffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b11 (void)
+{
+  return 0xbfffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b12 (void)
+{
+  return 0xbffffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b13 (void)
+{
+  return 0xbfffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b14 (void)
+{
+  return 0xbffULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b15 (void)
+{
+  return 0xbfULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+b16 (void)
+{
+  return 0xbULL;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r1 (void)
+{
+  return -0x124ULL << 48;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r2 (void)
+{
+  return -0x124ULL << 44;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r3 (void)
+{
+  return -0x124ULL << 40;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r4 (void)
+{
+  return -0x124ULL << 32;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r5 (void)
+{
+  return -0x124ULL << 28;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r6 (void)
+{
+  return -0x124ULL << 24;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r7 (void)
+{
+  return -0x124ULL << 20;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r8 (void)
+{
+  return -0x124ULL << 16;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r9 (void)
+{
+  return -0x124ULL << 12;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r10 (void)
+{
+  return -0x124ULL << 8;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r11 (void)
+{
+  return -0x124ULL << 4;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+r12 (void)
+{
+  return -0x124ULL << 0;
+}
+
+unsigned long long __attribute__ ((__noinline__, __noclone__))
+lis1 (void)
+{
+  return 0x89ab0000ffffULL;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst1.c b/gcc/testsuite/gcc.target/powerpc/rot_cst1.c
new file mode 100644
index 00000000000..30219dd1438
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rot_cst1.c
@@ -0,0 +1,68 @@
+/* { dg-do run { target lp64 } } */
+/* { dg-options "-O2" } */
+
+#include "rot_cst.h"
+
+struct fun {
+  unsigned long long (*f) (void);
+  unsigned long long val;
+};
+
+volatile struct fun values[] = {
+  { c1,  0xc000000000000000ULL },
+  { c2,  0xc00000000000000ULL },
+  { c3,  0xc0000000000000ULL },
+  { c4,  0xc000000000000ULL },
+  { c5,  0xc00000000000ULL },
+  { c6,  0xc0000000000ULL },
+  { c7,  0xc000000000ULL },
+  { c8,  0xc00000000ULL },
+  { c9,  0xc0000000ULL },
+  { c10, 0xc000000ULL },
+  { c11, 0xc00000ULL },
+  { c12, 0xc0000ULL },
+  { c13, 0xc000ULL },
+  { c14, 0xc00ULL },
+  { c15, 0xc0ULL },
+  { c16, 0xcULL },
+  { b1,  0xbfffffffffffffffULL },
+  { b2,  0xbffffffffffffffULL },
+  { b3,  0xbfffffffffffffULL },
+  { b4,  0xbffffffffffffULL },
+  { b5,  0xbfffffffffffULL },
+  { b6,  0xbffffffffffULL },
+  { b7,  0xbfffffffffULL },
+  { b8,  0xbffffffffULL },
+  { b9,  0xbfffffffULL },
+  { b10, 0xbffffffULL },
+  { b11, 0xbfffffULL },
+  { b12, 0xbffffULL },
+  { b13, 0xbfffULL },
+  { b14, 0xbffULL },
+  { b15, 0xbfULL },
+  { b16, 0xbULL },
+  { r1,  -0x124ULL << 48 },
+  { r2,  -0x124ULL << 44 },
+  { r3,  -0x124ULL << 40 },
+  { r4,  -0x124ULL << 32 },
+  { r5,  -0x124ULL << 28 },
+  { r6,  -0x124ULL << 24 },
+  { r7,  -0x124ULL << 20 },
+  { r8,  -0x124ULL << 16 },
+  { r9,  -0x124ULL << 12 },
+  { r10, -0x124ULL << 8 },
+  { r11, -0x124ULL << 4 },
+  { r12, -0x124ULL << 0 },
+  { lis1, 0x89ab0000ffffULL }
+};
+
+int
+main (void)
+{
+  volatile struct fun *t;
+
+  for (t = values; t < values + sizeof (values) / sizeof (values[0]); ++t)
+    if (t->f () != t->val)
+      __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst2.c b/gcc/testsuite/gcc.target/powerpc/rot_cst2.c
new file mode 100644
index 00000000000..d5d45ead043
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rot_cst2.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2" } */
+
+#include "rot_cst.h"
+
+/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 122 } } */

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2020-09-15  7:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  1:19 [RS6000] rtx_costs Alan Modra
2020-09-15  1:19 ` [RS6000] Count rldimi constant insns Alan Modra
2020-09-15 22:29   ` Segher Boessenkool
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs for PLUS/MINUS constant Alan Modra
2020-09-15 22:31   ` Segher Boessenkool
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs for AND Alan Modra
2020-09-15 18:15   ` will schmidt
2020-09-16  7:24     ` Alan Modra
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs comment Alan Modra
2020-09-16 23:21   ` Segher Boessenkool
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs multi-insn constants Alan Modra
2020-09-16 23:28   ` Segher Boessenkool
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs cost IOR Alan Modra
2020-09-17  0:02   ` Segher Boessenkool
2020-09-17  3:42     ` Alan Modra
2020-09-21 15:49       ` Segher Boessenkool
2020-09-21 23:54         ` Alan Modra
2020-09-15  1:19 ` [RS6000] rs6000_rtx_costs reduce cost for SETs Alan Modra
2020-09-17 17:51   ` Segher Boessenkool
2020-09-18  3:38     ` Alan Modra
2020-09-18 18:13       ` Segher Boessenkool
2020-09-21  7:07         ` Alan Modra
2020-09-15  1:19 ` [RS6000] rotate and mask constants Alan Modra
2020-09-15  7:16   ` Alan Modra [this message]
2020-09-21 15:56     ` Segher Boessenkool
2020-09-15 18:15 ` [RS6000] rtx_costs will schmidt
2020-10-07 23:06 [RS6000] rotate and mask constants Alan Modra
2020-10-08 19:13 ` will schmidt
     [not found] ` <20210112033310.GF26219@bubble.grove.modra.org>
2021-01-21 23:11   ` Alan Modra

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=20200915071608.GJ5452@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=bergner@vnet.ibm.com \
    --cc=gcc-patches@sourceware.org \
    --cc=segher@kernel.crashing.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).