[2/7] PowerPC tests: Add PLI/PADDI tests.

Message ID 1591041222-24243-3-git-send-email-meissner@linux.ibm.com
State New
Headers show
Series
  • [1/7] PowerPC tests: Add prefixed/pcrel tests.
Related show

Commit Message

Jakub Jelinek via Gcc-patches June 1, 2020, 7:53 p.m.
Add tests for -mcpu=future that test the generation of PADDI (and PLI which
becomes PADDI).

2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/prefix-add.c: New test.
	* gcc.target/powerpc/prefix-si-constant.c: New test.
	* gcc.target/powerpc/prefix-di-constant.c: New test.
---
 gcc/testsuite/gcc.target/powerpc/prefix-add.c         | 14 ++++++++++++++
 gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c | 13 +++++++++++++
 gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c       |  0
 gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c | 12 ++++++++++++
 4 files changed, 39 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-add.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c

-- 
1.8.3.1

Comments

Segher Boessenkool June 25, 2020, 4:52 p.m. | #1
On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:
> Add tests for -mcpu=future that test the generation of PADDI (and PLI which

> becomes PADDI).

> 

> 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

> 

> 	* gcc.target/powerpc/prefix-add.c: New test.

> 	* gcc.target/powerpc/prefix-si-constant.c: New test.

> 	* gcc.target/powerpc/prefix-di-constant.c: New test.


This is okay for trunk (with required changes: -mdejagnu-cpu=power10,
and the selector names have changed to be something with power10 instead
of something with future; please retest before commit).

Thanks!


Segher
Jakub Jelinek via Gcc-patches June 27, 2020, 5:49 a.m. | #2
On Thu, Jun 25, 2020 at 11:52:50AM -0500, Segher Boessenkool wrote:
> On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:

> > Add tests for -mcpu=future that test the generation of PADDI (and PLI which

> > becomes PADDI).

> > 

> > 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

> > 

> > 	* gcc.target/powerpc/prefix-add.c: New test.

> > 	* gcc.target/powerpc/prefix-si-constant.c: New test.

> > 	* gcc.target/powerpc/prefix-di-constant.c: New test.

> 

> This is okay for trunk (with required changes: -mdejagnu-cpu=power10,

> and the selector names have changed to be something with power10 instead

> of something with future; please retest before commit).


Done.  I was just about to resubmit the patches with the -mcpu=power10 changes.
I did retest on power8/power9 little endian, and power8 big endian (both
32/64-bit).  In running the tests, I discovered 3 of the tests that needed
ILP64 to test the particular code that I was looking for that I previously
hadn't flagged.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797
Jakub Jelinek via Gcc-patches June 27, 2020, 5:57 a.m. | #3
On Thu, Jun 25, 2020 at 11:52:50AM -0500, Segher Boessenkool wrote:
> On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:

> > Add tests for -mcpu=future that test the generation of PADDI (and PLI which

> > becomes PADDI).

> > 

> > 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

> > 

> > 	* gcc.target/powerpc/prefix-add.c: New test.

> > 	* gcc.target/powerpc/prefix-si-constant.c: New test.

> > 	* gcc.target/powerpc/prefix-di-constant.c: New test.

> 

> This is okay for trunk (with required changes: -mdejagnu-cpu=power10,

> and the selector names have changed to be something with power10 instead

> of something with future; please retest before commit).


Since all of these tests are for code that is in GCC 10, can I apply these
patches to the GCC 10 branch after the completion of the -mcpu=power10 changes
for GCC 10 and a suitable waiting period and retest?

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797
Segher Boessenkool June 27, 2020, 6:55 p.m. | #4
On Sat, Jun 27, 2020 at 01:49:23AM -0400, Michael Meissner wrote:
> On Thu, Jun 25, 2020 at 11:52:50AM -0500, Segher Boessenkool wrote:

> > On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:

> > > Add tests for -mcpu=future that test the generation of PADDI (and PLI which

> > > becomes PADDI).

> > > 

> > > 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

> > > 

> > > 	* gcc.target/powerpc/prefix-add.c: New test.

> > > 	* gcc.target/powerpc/prefix-si-constant.c: New test.

> > > 	* gcc.target/powerpc/prefix-di-constant.c: New test.

> > 

> > This is okay for trunk (with required changes: -mdejagnu-cpu=power10,

> > and the selector names have changed to be something with power10 instead

> > of something with future; please retest before commit).

> 

> Done.  I was just about to resubmit the patches with the -mcpu=power10 changes.

> I did retest on power8/power9 little endian, and power8 big endian (both

> 32/64-bit).  In running the tests, I discovered 3 of the tests that needed

> ILP64 to test the particular code that I was looking for that I previously

> hadn't flagged.


Please post what you committed, then?


Segher
Segher Boessenkool June 27, 2020, 6:58 p.m. | #5
On Sat, Jun 27, 2020 at 01:57:52AM -0400, Michael Meissner wrote:
> On Thu, Jun 25, 2020 at 11:52:50AM -0500, Segher Boessenkool wrote:

> > On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:

> > > Add tests for -mcpu=future that test the generation of PADDI (and PLI which

> > > becomes PADDI).

> > > 

> > > 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

> > > 

> > > 	* gcc.target/powerpc/prefix-add.c: New test.

> > > 	* gcc.target/powerpc/prefix-si-constant.c: New test.

> > > 	* gcc.target/powerpc/prefix-di-constant.c: New test.

> > 

> > This is okay for trunk (with required changes: -mdejagnu-cpu=power10,

> > and the selector names have changed to be something with power10 instead

> > of something with future; please retest before commit).

> 

> Since all of these tests are for code that is in GCC 10, can I apply these

> patches to the GCC 10 branch after the completion of the -mcpu=power10 changes

> for GCC 10 and a suitable waiting period and retest?


Sure, thanks!


Segher
Jakub Jelinek via Gcc-patches June 29, 2020, 6:23 p.m. | #6
From 212475e5757fe3335cba30c9c3eec1707ac0c271 Mon Sep 17 00:00:00 2001
From: Michael Meissner <meissner@linux.ibm.com>

Date: Sat, 27 Jun 2020 00:40:48 -0500
Subject: [PATCH, committed] Add PowerPC tests for power10.

2020-06-27  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/prefix-add.c: New test.
	* gcc.target/powerpc/prefix-si-constant.c: New test.
	* gcc.target/powerpc/prefix-di-constant.c: New test.
	* gcc.target/powerpc/prefix-ds-dq.c: New test.
	* gcc.target/powerpc/prefix-no-update.c: New test.
	* gcc.target/powerpc/prefix-large-dd.c: New test.
	* gcc.target/powerpc/prefix-large-df.c: New test.
	* gcc.target/powerpc/prefix-large-di.c: New test.
	* gcc.target/powerpc/prefix-large-hi.c: New test.
	* gcc.target/powerpc/prefix-large-kf.c: New test.
	* gcc.target/powerpc/prefix-large-qi.c: New test.
	* gcc.target/powerpc/prefix-large-sd.c: New test.
	* gcc.target/powerpc/prefix-large-sf.c: New test.
	* gcc.target/powerpc/prefix-large-si.c: New test.
	* gcc.target/powerpc/prefix-large-udi.c: New test.
	* gcc.target/powerpc/prefix-large-uhi.c: New test.
	* gcc.target/powerpc/prefix-large-uqi.c: New test.
	* gcc.target/powerpc/prefix-large-usi.c: New test.
	* gcc.target/powerpc/prefix-large-v2df.c: New test.
	* gcc.target/powerpc/prefix-large.h: Include file for new tests.
	* gcc.target/powerpc/prefix-pcrel-dd.c: New test.
	* gcc.target/powerpc/prefix-pcrel-df.c: New test.
	* gcc.target/powerpc/prefix-pcrel-di.c: New test.
	* gcc.target/powerpc/prefix-pcrel-hi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-kf.c: New test.
	* gcc.target/powerpc/prefix-pcrel-qi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-sd.c: New test.
	* gcc.target/powerpc/prefix-pcrel-sf.c: New test.
	* gcc.target/powerpc/prefix-pcrel-si.c: New test.
	* gcc.target/powerpc/prefix-pcrel-udi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-uhi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-uqi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-usi.c: New test.
	* gcc.target/powerpc/prefix-pcrel-v2df.c: New test.
	* gcc.target/powerpc/prefix-pcrel.h: Include file for new tests.
	* gcc.target/powerpc/prefix-stack-protect.c: New test.
---
 gcc/testsuite/gcc.target/powerpc/prefix-add.c |  14 ++
 .../gcc.target/powerpc/prefix-di-constant.c   |  13 ++
 .../gcc.target/powerpc/prefix-ds-dq.c         | 161 ++++++++++++++++++
 .../gcc.target/powerpc/prefix-large-dd.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-df.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-di.c      |  14 ++
 .../gcc.target/powerpc/prefix-large-hi.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-kf.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-qi.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-sd.c      |  19 +++
 .../gcc.target/powerpc/prefix-large-sf.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-si.c      |  13 ++
 .../gcc.target/powerpc/prefix-large-udi.c     |  14 ++
 .../gcc.target/powerpc/prefix-large-uhi.c     |  13 ++
 .../gcc.target/powerpc/prefix-large-uqi.c     |  13 ++
 .../gcc.target/powerpc/prefix-large-usi.c     |  13 ++
 .../gcc.target/powerpc/prefix-large-v2df.c    |  13 ++
 .../gcc.target/powerpc/prefix-large.h         |  40 +++++
 .../gcc.target/powerpc/prefix-no-update.c     |  51 ++++++
 .../gcc.target/powerpc/prefix-pcrel-dd.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-df.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-di.c      |  14 ++
 .../gcc.target/powerpc/prefix-pcrel-hi.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-kf.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-qi.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-sd.c      |  15 ++
 .../gcc.target/powerpc/prefix-pcrel-sf.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-si.c      |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-udi.c     |  14 ++
 .../gcc.target/powerpc/prefix-pcrel-uhi.c     |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-uqi.c     |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-usi.c     |  13 ++
 .../gcc.target/powerpc/prefix-pcrel-v2df.c    |  13 ++
 .../gcc.target/powerpc/prefix-pcrel.h         |  41 +++++
 .../gcc.target/powerpc/prefix-si-constant.c   |  12 ++
 .../gcc.target/powerpc/prefix-stack-protect.c |  21 +++
 36 files changed, 729 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-add.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-dd.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-df.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-di.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-hi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-kf.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-qi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-sd.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-sf.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-si.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-udi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-uhi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-uqi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-usi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large-v2df.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-large.h
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-no-update.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-dd.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-df.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-di.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-hi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-kf.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-qi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sd.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sf.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-si.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-udi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uhi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uqi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-usi.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel-v2df.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-pcrel.h
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c

diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-add.c b/gcc/testsuite/gcc.target/powerpc/prefix-add.c
new file mode 100644
index 00000000000..0027406e457
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-add.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Test that PADDI is generated to add a large constant.  */
+unsigned long
+add (unsigned long a)
+{
+  return a + 0x12345U;
+}
+
+/* { dg-final { scan-assembler     {\mpaddi\M} } } */
+/* { dg-final { scan-assembler-not {\maddi\M}  } } */
+/* { dg-final { scan-assembler-not {\maddis\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
new file mode 100644
index 00000000000..aca7897cd92
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Test that PLI (PADDI) is generated to load a large constant.  */
+unsigned long long
+large (void)
+{
+  return 0x12345678ULL;
+}
+
+/* { dg-final { scan-assembler {\mpli\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
new file mode 100644
index 00000000000..554cd0c1bea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
@@ -0,0 +1,161 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether we generate a prefixed load/store operation for addresses that
+   don't meet DS/DQ offset constraints.  64-bit is needed for testing the use
+   of the PLWA instruciton.  */
+
+struct packed_struct
+{
+  long long pad;			/* offset  0 bytes.  */
+  unsigned char pad_uc;			/* offset  8 bytes.  */
+  unsigned char uc;			/* offset  9 bytes.  */
+
+  unsigned char pad_sc[sizeof (long long) - sizeof (unsigned char)];
+  unsigned char sc;			/* offset  17 bytes.  */
+
+  unsigned char pad_us[sizeof (long long) - sizeof (signed char)];
+  unsigned short us;			/* offset  25 bytes.  */
+
+  unsigned char pad_ss[sizeof (long long) - sizeof (unsigned short)];
+  short ss;				/* offset 33 bytes.  */
+
+  unsigned char pad_ui[sizeof (long long) - sizeof (short)];
+  unsigned int ui;			/* offset 41 bytes.  */
+
+  unsigned char pad_si[sizeof (long long) - sizeof (unsigned int)];
+  unsigned int si;			/* offset 49 bytes.  */
+
+  unsigned char pad_f[sizeof (long long) - sizeof (int)];
+  float f;				/* offset 57 bytes.  */
+
+  unsigned char pad_d[sizeof (long long) - sizeof (float)];
+  double d;				/* offset 65 bytes.  */
+  __float128 f128;			/* offset 73 bytes.  */
+} __attribute__((packed));
+
+unsigned char
+load_uc (struct packed_struct *p)
+{
+  return p->uc;				/* LBZ 3,9(3).  */
+}
+
+signed char
+load_sc (struct packed_struct *p)
+{
+  return p->sc;				/* LBZ 3,17(3) + EXTSB 3,3.  */
+}
+
+unsigned short
+load_us (struct packed_struct *p)
+{
+  return p->us;				/* LHZ 3,25(3).  */
+}
+
+short
+load_ss (struct packed_struct *p)
+{
+  return p->ss;				/* LHA 3,33(3).  */
+}
+
+unsigned int
+load_ui (struct packed_struct *p)
+{
+  return p->ui;				/* LWZ 3,41(3).  */
+}
+
+int
+load_si (struct packed_struct *p)
+{
+  return p->si;				/* PLWA 3,49(3).  */
+}
+
+float
+load_float (struct packed_struct *p)
+{
+  return p->f;				/* LFS 1,57(3).  */
+}
+
+double
+load_double (struct packed_struct *p)
+{
+  return p->d;				/* LFD 1,65(3).  */
+}
+
+__float128
+load_float128 (struct packed_struct *p)
+{
+  return p->f128;			/* PLXV 34,73(3).  */
+}
+
+void
+store_uc (struct packed_struct *p, unsigned char uc)
+{
+  p->uc = uc;				/* STB 4,9(3).  */
+}
+
+void
+store_sc (struct packed_struct *p, signed char sc)
+{
+  p->sc = sc;				/* STB 4,17(3).  */
+}
+
+void
+store_us (struct packed_struct *p, unsigned short us)
+{
+  p->us = us;				/* STH 4,25(3).  */
+}
+
+void
+store_ss (struct packed_struct *p, signed short ss)
+{
+  p->ss = ss;				/* STH 4,33(3).  */
+}
+
+void
+store_ui (struct packed_struct *p, unsigned int ui)
+{
+  p->ui = ui;				/* STW 4,41(3).  */
+}
+
+void
+store_si (struct packed_struct *p, signed int si)
+{
+  p->si = si;				/* STW 4,49(3).  */
+}
+
+void
+store_float (struct packed_struct *p, float f)
+{
+  p->f = f;				/* STFS 1,57(3).  */
+}
+
+void
+store_double (struct packed_struct *p, double d)
+{
+  p->d = d;				/* STFD 1,65(3).  */
+}
+
+void
+store_float128 (struct packed_struct *p, __float128 f128)
+{
+  p->f128 = f128;			/* PSTXV 34,1(3).  */
+}
+
+/* { dg-final { scan-assembler-times {\mextsb\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mlbz\M}   2 } } */
+/* { dg-final { scan-assembler-times {\mlfd\M}   1 } } */
+/* { dg-final { scan-assembler-times {\mlfs\M}   1 } } */
+/* { dg-final { scan-assembler-times {\mlha\M}   1 } } */
+/* { dg-final { scan-assembler-times {\mlhz\M}   1 } } */
+/* { dg-final { scan-assembler-times {\mlwz\M}   1 } } */
+/* { dg-final { scan-assembler-times {\mplwa\M}  1 } } */
+/* { dg-final { scan-assembler-times {\mplxv\M}  1 } } */
+/* { dg-final { scan-assembler-times {\mpstxv\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mstb\M}   2 } } */
+/* { dg-final { scan-assembler-times {\mstfd\M}  1 } } */
+/* { dg-final { scan-assembler-times {\mstfs\M}  1 } } */
+/* { dg-final { scan-assembler-times {\msth\M}   2 } } */
+/* { dg-final { scan-assembler-times {\mstw\M}   2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-dd.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-dd.c
new file mode 100644
index 00000000000..d3a35977de8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-dd.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the _Decimal64 type.  */
+
+#define TYPE _Decimal64
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplfd\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-df.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-df.c
new file mode 100644
index 00000000000..49a049b777a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-df.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the double type.  */
+
+#define TYPE double
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplfd\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-di.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-di.c
new file mode 100644
index 00000000000..399f6967ed9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-di.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the long long type.  */
+
+#define TYPE long long
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mpld\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-hi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-hi.c
new file mode 100644
index 00000000000..18380cac49b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-hi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the short type.  */
+
+#define TYPE short
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplh[az]\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpsth\M}     2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-kf.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-kf.c
new file mode 100644
index 00000000000..a6038bd86ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-kf.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the _Float128 type.  */
+
+#define TYPE _Float128
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplxv\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstxv\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-qi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-qi.c
new file mode 100644
index 00000000000..24cdac16e99
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-qi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the signed char type.  */
+
+#define TYPE signed char
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplbz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstb\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-sd.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-sd.c
new file mode 100644
index 00000000000..beb2d9f62b0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-sd.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the _Decimal32 type.  Note, the _Decimal32 type will not generate any
+   prefixed load or stores, because there is no prefixed load/store instruction
+   to load up a vector register as a zero extended 32-bit integer.  So we count
+   the number of load addresses that are generated.  */
+
+#define TYPE _Decimal32
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mpli\M}    3 } } */
+/* { dg-final { scan-assembler-times {\mlfiwzx\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mstfiwx\M} 2 } } */
+
+
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-sf.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-sf.c
new file mode 100644
index 00000000000..9fde1f0a7a6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-sf.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the float type.  */
+
+#define TYPE float
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplfs\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfs\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-si.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-si.c
new file mode 100644
index 00000000000..876a013a2ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-si.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the _Decimal64 type.  */
+
+#define TYPE int
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplw[az]\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstw\M}     2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-udi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-udi.c
new file mode 100644
index 00000000000..e6365d37d0c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-udi.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the unsigned long long type.  */
+
+#define TYPE unsigned long long
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mpld\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-uhi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-uhi.c
new file mode 100644
index 00000000000..3523767a6f0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-uhi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the unsigned short type.  */
+
+#define TYPE unsigned short
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplhz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpsth\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-uqi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-uqi.c
new file mode 100644
index 00000000000..f251c4a12c2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-uqi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the unsigned char type.  */
+
+#define TYPE unsigned char
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplbz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstb\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-usi.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-usi.c
new file mode 100644
index 00000000000..d60036da026
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-usi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the unsigned int type.  */
+
+#define TYPE unsigned int
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplwz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstw\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large-v2df.c b/gcc/testsuite/gcc.target/powerpc/prefix-large-v2df.c
new file mode 100644
index 00000000000..f6d042f0984
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large-v2df.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether prefixed instructions with large numeric offsets are generated
+   for the vector double type.  */
+
+#define TYPE vector double
+
+#include "prefix-large.h"
+
+/* { dg-final { scan-assembler-times {\mplxv\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstxv\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-large.h b/gcc/testsuite/gcc.target/powerpc/prefix-large.h
new file mode 100644
index 00000000000..07b38ae0875
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-large.h
@@ -0,0 +1,40 @@
+/* Common tests for prefixed instructions testing whether we can generate a
+   34-bit offset using 1 instruction.  */
+
+#ifndef TYPE
+#define TYPE unsigned int
+#endif
+
+#if !defined(DO_ADD) && !defined(DO_VALUE) && !defined(DO_SET)
+#define DO_ADD		1
+#define DO_VALUE	1
+#define DO_SET		1
+#endif
+
+#ifndef CONSTANT
+#define CONSTANT	0x12480UL
+#endif
+
+#if DO_ADD
+void
+add (TYPE *p, TYPE a)
+{
+  p[CONSTANT] += a;
+}
+#endif
+
+#if DO_VALUE
+TYPE
+value (TYPE *p)
+{
+  return p[CONSTANT];
+}
+#endif
+
+#if DO_SET
+void
+set (TYPE *p, TYPE a)
+{
+  p[CONSTANT] = a;
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c b/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c
new file mode 100644
index 00000000000..837fcd77c0b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Make sure that we don't generate a prefixed form of the load and store with
+   update instructions (i.e. instead of generating LWZU we have to generate
+   PLWZ plus a PADDI).  */
+
+#ifndef SIZE
+#define SIZE 50000
+#endif
+
+struct foo {
+  unsigned int field;
+  char pad[SIZE];
+};
+
+struct foo *inc_load (struct foo *p, unsigned int *q)
+{
+  *q = (++p)->field;	/* PLWZ, PADDI, STW.  */
+  return p;
+}
+
+struct foo *dec_load (struct foo *p, unsigned int *q)
+{
+  *q = (--p)->field;	/* PLWZ, PADDI, STW.  */
+  return p;
+}
+
+struct foo *inc_store (struct foo *p, unsigned int *q)
+{
+  (++p)->field = *q;	/* LWZ, PADDI, PSTW.  */
+  return p;
+}
+
+struct foo *dec_store (struct foo *p, unsigned int *q)
+{
+  (--p)->field = *q;	/* LWZ, PADDI, PSTW.  */
+  return p;
+}
+
+/* { dg-final { scan-assembler-times {\mlwz\M}    2 } } */
+/* { dg-final { scan-assembler-times {\mstw\M}    2 } } */
+/* { dg-final { scan-assembler-times {\mpaddi\M}  4 } } */
+/* { dg-final { scan-assembler-times {\mplwz\M}   2 } } */
+/* { dg-final { scan-assembler-times {\mpstw\M}   2 } } */
+/* { dg-final { scan-assembler-not   {\mplwzu\M}    } } */
+/* { dg-final { scan-assembler-not   {\mpstwu\M}    } } */
+/* { dg-final { scan-assembler-not   {\maddis\M}    } } */
+/* { dg-final { scan-assembler-not   {\maddi\M}     } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-dd.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-dd.c
new file mode 100644
index 00000000000..165aa2f9aa0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-dd.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   _Decimal64 type.  */
+
+#define TYPE _Decimal64
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplfd\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-df.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-df.c
new file mode 100644
index 00000000000..b7fd84e7de2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-df.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   double type.  */
+
+#define TYPE double
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplfd\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-di.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-di.c
new file mode 100644
index 00000000000..90081e452a2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-di.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   long long type.  */
+
+#define TYPE long long
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mpld\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-hi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-hi.c
new file mode 100644
index 00000000000..71357b7d149
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-hi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   short type.  */
+
+#define TYPE short
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplh[az]\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpsth\M}     2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-kf.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-kf.c
new file mode 100644
index 00000000000..94bcbdc67d9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-kf.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   _Float128 type.  */
+
+#define TYPE _Float128
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplxv\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstxv\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-qi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-qi.c
new file mode 100644
index 00000000000..472360c08f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-qi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   signed char type.  */
+
+#define TYPE signed char
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplbz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstb\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sd.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sd.c
new file mode 100644
index 00000000000..94c076d3ed6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sd.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   _Decimal32 type.  Note, the _Decimal32 type will not generate any prefixed
+   load or stores, because there is no prefixed load/store instruction to load
+   up a vector register as a zero extended 32-bit integer.  So we count the
+   number of load addresses that are generated.  */
+
+#define TYPE _Decimal32
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mpla\M}  3 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sf.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sf.c
new file mode 100644
index 00000000000..0e907e07d00
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-sf.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   float type.  */
+
+#define TYPE float
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplfs\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstfs\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-si.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-si.c
new file mode 100644
index 00000000000..fb90fcd878f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-si.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   int type.  */
+
+#define TYPE int
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplw[az]\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstw\M}     2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-udi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-udi.c
new file mode 100644
index 00000000000..940040fc5aa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-udi.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   unsigned long long type.  */
+
+#define TYPE unsigned long long
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mpld\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstd\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uhi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uhi.c
new file mode 100644
index 00000000000..5c8d082e831
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uhi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   unsigned short type.  */
+
+#define TYPE unsigned short
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplhz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpsth\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uqi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uqi.c
new file mode 100644
index 00000000000..68999192d54
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-uqi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   unsigned char type.  */
+
+#define TYPE unsigned char
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplbz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstb\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-usi.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-usi.c
new file mode 100644
index 00000000000..5948f8254c3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-usi.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   unsigned int type.  */
+
+#define TYPE unsigned int
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplwz\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstw\M}  2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-v2df.c b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-v2df.c
new file mode 100644
index 00000000000..d626b8a128e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel-v2df.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_pcrel } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Tests whether pc-relative prefixed instructions are generated for the
+   vector double type.  */
+
+#define TYPE vector double
+
+#include "prefix-pcrel.h"
+
+/* { dg-final { scan-assembler-times {\mplxv\M}  2 } } */
+/* { dg-final { scan-assembler-times {\mpstxv\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-pcrel.h b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel.h
new file mode 100644
index 00000000000..26175dc7d1e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-pcrel.h
@@ -0,0 +1,41 @@
+/* Common tests for prefixed instructions testing whether pc-relative prefixed
+   instructions are generated for each type.  */
+
+#ifndef TYPE
+#define TYPE unsigned int
+#endif
+
+static TYPE a;
+
+/* Make sure a is not optimized away.  */
+TYPE *p = &a;
+
+#if !defined(DO_ADD) && !defined(DO_VALUE) && !defined(DO_SET)
+#define DO_ADD		1
+#define DO_VALUE	1
+#define DO_SET		1
+#endif
+
+#if DO_ADD
+void
+add (TYPE b)
+{
+  a += b;
+}
+#endif
+
+#if DO_VALUE
+TYPE
+value (void)
+{
+  return a;
+}
+#endif
+
+#if DO_SET
+void
+set (TYPE b)
+{
+  a = b;
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c b/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c
new file mode 100644
index 00000000000..6403aa8024c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Test that PLI (PADDI) is generated to load a large constant for SImode.  */
+void
+large_si (unsigned int *p)
+{
+  *p = 0x12345U;
+}
+
+/* { dg-final { scan-assembler {\mpli\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c b/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c
new file mode 100644
index 00000000000..ca3b3dfd89f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -fstack-protector-strong" } */
+
+/* Test that we can handle large stack frames with -fstack-protector-strong and
+   prefixed addressing.  This was originally discovered when trying to build
+   glibc with -mcpu=power10, and vfwprintf.c failed because it used
+   -fstack-protector-strong.  It needs 64-bit due to the size of the stack.  */
+
+extern long foo (char *);
+
+long
+bar (void)
+{
+  char buffer[0x20000];
+  return foo (buffer) + 1;
+}
+
+/* { dg-final { scan-assembler {\mpld\M}  } } */
+/* { dg-final { scan-assembler {\mpstd\M} } } */
-- 
2.17.1


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797
Segher Boessenkool June 29, 2020, 6:42 p.m. | #7
Hi!

On Mon, Jun 29, 2020 at 02:23:22PM -0400, Michael Meissner wrote:
> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c

> @@ -0,0 +1,13 @@

> +/* { dg-do compile } */

> +/* { dg-require-effective-target powerpc_prefixed_addr } */

> +/* { dg-require-effective-target lp64 } */


Please always say (_in the test_) why something is required, if it isn't
obvious.

> +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> +

> +/* Test that PLI (PADDI) is generated to load a large constant.  */

> +unsigned long long

> +large (void)

> +{

> +  return 0x12345678ULL;

> +}

> +

> +/* { dg-final { scan-assembler {\mpli\M} } } */


I have no idea why 64-bit mode (or 64-bit addressing) is needed here.
*Is* it needed?

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c

> @@ -0,0 +1,161 @@

> +/* { dg-do compile } */

> +/* { dg-require-effective-target powerpc_prefixed_addr } */

> +/* { dg-require-effective-target lp64 } */

> +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */


> +  unsigned int si;			/* offset 49 bytes.  */


> +int

> +load_si (struct packed_struct *p)

> +{

> +  return p->si;				/* PLWA 3,49(3).  */

> +}


Here it is because this would be just lwz on 32-bit.

But that is the only difference, so you could just make that single test
conditional, not the whole file.

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c

> @@ -0,0 +1,51 @@

> +/* { dg-do compile } */

> +/* { dg-require-effective-target powerpc_prefixed_addr } */

> +/* { dg-require-effective-target lp64 } */

> +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */


For this testcase, I have no idea at all why you want lp64?

Thanks,


Segher
Jakub Jelinek via Gcc-patches June 30, 2020, 5:58 a.m. | #8
On Mon, Jun 29, 2020 at 01:42:56PM -0500, Segher Boessenkool wrote:
> Hi!

> 

> On Mon, Jun 29, 2020 at 02:23:22PM -0400, Michael Meissner wrote:

> > --- /dev/null

> > +++ b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c

> > @@ -0,0 +1,13 @@

> > +/* { dg-do compile } */

> > +/* { dg-require-effective-target powerpc_prefixed_addr } */

> > +/* { dg-require-effective-target lp64 } */

> 

> Please always say (_in the test_) why something is required, if it isn't

> obvious.

> 

> > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> > +

> > +/* Test that PLI (PADDI) is generated to load a large constant.  */

> > +unsigned long long

> > +large (void)

> > +{

> > +  return 0x12345678ULL;

> > +}

> > +

> > +/* { dg-final { scan-assembler {\mpli\M} } } */

> 

> I have no idea why 64-bit mode (or 64-bit addressing) is needed here.

> *Is* it needed?


Yes it is needed.  Otherwise two separate load immediates would be needed to
load each part of the DI constant that is held in 2 registers.

> > --- /dev/null

> > +++ b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c

> > @@ -0,0 +1,161 @@

> > +/* { dg-do compile } */

> > +/* { dg-require-effective-target powerpc_prefixed_addr } */

> > +/* { dg-require-effective-target lp64 } */

> > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> 

> > +  unsigned int si;			/* offset 49 bytes.  */

> 

> > +int

> > +load_si (struct packed_struct *p)

> > +{

> > +  return p->si;				/* PLWA 3,49(3).  */

> > +}

> 

> Here it is because this would be just lwz on 32-bit.

> 

> But that is the only difference, so you could just make that single test

> conditional, not the whole file.

> 

> > --- /dev/null

> > +++ b/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c

> > @@ -0,0 +1,51 @@

> > +/* { dg-do compile } */

> > +/* { dg-require-effective-target powerpc_prefixed_addr } */

> > +/* { dg-require-effective-target lp64 } */

> > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> 

> For this testcase, I have no idea at all why you want lp64?


Becuase to show the bug you need a stack frame larger than 64K.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797
Segher Boessenkool July 1, 2020, 12:51 a.m. | #9
Hi!

On Tue, Jun 30, 2020 at 01:58:50AM -0400, Michael Meissner wrote:
> On Mon, Jun 29, 2020 at 01:42:56PM -0500, Segher Boessenkool wrote:

> > On Mon, Jun 29, 2020 at 02:23:22PM -0400, Michael Meissner wrote:

> > > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> > > +

> > > +/* Test that PLI (PADDI) is generated to load a large constant.  */

> > > +unsigned long long

> > > +large (void)

> > > +{

> > > +  return 0x12345678ULL;

> > > +}

> > > +

> > > +/* { dg-final { scan-assembler {\mpli\M} } } */

> > 

> > I have no idea why 64-bit mode (or 64-bit addressing) is needed here.

> > *Is* it needed?

> 

> Yes it is needed.  Otherwise two separate load immediates would be needed to

> load each part of the DI constant that is held in 2 registers.


But that will work just fine, because one of those insns will be a pli,
exactly as tested for!

> > > --- /dev/null

> > > +++ b/gcc/testsuite/gcc.target/powerpc/prefix-no-update.c

> > > @@ -0,0 +1,51 @@

> > > +/* { dg-do compile } */

> > > +/* { dg-require-effective-target powerpc_prefixed_addr } */

> > > +/* { dg-require-effective-target lp64 } */

> > > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

> > 

> > For this testcase, I have no idea at all why you want lp64?

> 

> Becuase to show the bug you need a stack frame larger than 64K.


I don't see it?  (Also, why would that require lp64?)


Segher

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-add.c b/gcc/testsuite/gcc.target/powerpc/prefix-add.c
new file mode 100644
index 0000000..26ef23e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-add.c
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=future" } */
+
+/* Test that PADDI is generated to add a large constant.  */
+unsigned long
+add (unsigned long a)
+{
+  return a + 0x12345U;
+}
+
+/* { dg-final { scan-assembler     {\mpaddi\M} } } */
+/* { dg-final { scan-assembler-not {\maddi\M}  } } */
+/* { dg-final { scan-assembler-not {\maddis\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
new file mode 100644
index 0000000..389fdaa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-di-constant.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mdejagnu-cpu=future" } */
+
+/* Test that PLI (PADDI) is generated to load a large constant.  */
+unsigned long long
+large (void)
+{
+  return 0x12345678ULL;
+}
+
+/* { dg-final { scan-assembler {\mpli\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c b/gcc/testsuite/gcc.target/powerpc/prefix-ds-dq.c
new file mode 100644
index 0000000..e69de29
diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c b/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c
new file mode 100644
index 0000000..269fc0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-si-constant.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=future" } */
+
+/* Test that PLI (PADDI) is generated to load a large constant for SImode.  */
+void
+large_si (unsigned int *p)
+{
+  *p = 0x12345U;
+}
+
+/* { dg-final { scan-assembler {\mpli\M} } } */