Re: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants
On Fri, Nov 5, 2021 at 3:24 PM will schmidt wrote: > > On Fri, 2021-11-05 at 00:10 -0400, Michael Meissner wrote: > > Generate XXSPLTIDP for vectors on power10. > > > > This patch implements XXSPLTIDP support for all vector constants. The > > XXSPLTIDP instruction is given a 32-bit immediate that is converted to a > > vector > > of two DFmode constants. The immediate is in SFmode format, so only > > constants > > that fit as SFmode values can be loaded with XXSPLTIDP. > > > > The constraint (eP) added in the previous patch for XXSPLTIW is also used > > for XXSPLTIDP. > > > > ok > > > > DImode scalar constants are not handled. This is due to the majority of > > DImode > > constants will be in the GPR registers. With vector registers, you have the > > problem that XXSPLTIDP splats the double word into both elements of the > > vector. However, if TImode is loaded with an integer constant, it wants a > > full > > 128-bit constant. > > This may be worth as adding to a todo somewhere in the code. > > > > > SFmode and DFmode scalar constants are not handled in this patch. The > > support for for those constants will be in the next patch. > > ok > > > > > I have added a temporary switch (-msplat-float-constant) to control whether > > or > > not the XXSPLTIDP instruction is generated. > > > > I added 2 new tests to test loading up V2DI and V2DF vector constants. > > > > > > > > 2021-11-05 Michael Meissner > > > > gcc/ > > > > * config/rs6000/predicates.md (easy_fp_constant): Add support for > > generating XXSPLTIDP. > > (vsx_prefixed_constant): Likewise. > > (easy_vector_constant): Likewise. > > * config/rs6000/rs6000-protos.h (constant_generates_xxspltidp): > > New declaration. > > * config/rs6000/rs6000.c (output_vec_const_move): Add support for > > generating XXSPLTIDP. > > (prefixed_xxsplti_p): Likewise. > > (constant_generates_xxspltidp): New function. > > * config/rs6000/rs6000.opt (-msplat-float-constant): New debug option. > > > > gcc/testsuite/ > > > > * gcc.target/powerpc/pr86731-fwrapv-longlong.c: Update insn > > regex for power10. > > * gcc.target/powerpc/vec-splat-constant-v2df.c: New test. > > * gcc.target/powerpc/vec-splat-constant-v2di.c: New test. > > --- > > > ok > > > gcc/config/rs6000/predicates.md | 9 ++ > > gcc/config/rs6000/rs6000-protos.h | 1 + > > gcc/config/rs6000/rs6000.c| 108 ++ > > gcc/config/rs6000/rs6000.opt | 4 + > > .../powerpc/pr86731-fwrapv-longlong.c | 9 +- > > .../powerpc/vec-splat-constant-v2df.c | 64 +++ > > .../powerpc/vec-splat-constant-v2di.c | 50 > > 7 files changed, 241 insertions(+), 4 deletions(-) > > create mode 100644 > > gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2df.c > > create mode 100644 > > gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2di.c > > > > diff --git a/gcc/config/rs6000/predicates.md > > b/gcc/config/rs6000/predicates.md > > index ed6252bd0c4..d748b11857c 100644 > > --- a/gcc/config/rs6000/predicates.md > > +++ b/gcc/config/rs6000/predicates.md > > @@ -610,6 +610,9 @@ (define_predicate "easy_fp_constant" > > > >if (constant_generates_xxspltiw (_const)) > > return true; > > + > > + if (constant_generates_xxspltidp (_const)) > > + return true; > > } > > > >/* Otherwise consider floating point constants hard, so that the > > @@ -653,6 +656,9 @@ (define_predicate "vsx_prefixed_constant" > >if (constant_generates_xxspltiw (_const)) > > return true; > > > > + if (constant_generates_xxspltidp (_const)) > > +return true; > > + > >return false; > > }) > > > > @@ -727,6 +733,9 @@ (define_predicate "easy_vector_constant" > > > > if (constant_generates_xxspltiw (_const)) > > return true; > > + > > + if (constant_generates_xxspltidp (_const)) > > + return true; > > } > > > ok > > > > >if (TARGET_P9_VECTOR > > diff --git a/gcc/config/rs6000/rs6000-protos.h > > b/gcc/config/rs6000/rs6000-protos.h > > index 99c6a671289..2d28df7442d 100644 > > --- a/gcc/config/rs6000/rs6000-protos.h > > +++ b/gcc/config/rs6000/rs6000-protos.h > > @@ -253,6 +253,7 @@ extern bool vec_const_128bit_to_bytes (rtx, > > machine_mode, > > vec_const_128bit_type *); > > extern unsigned constant_generates_lxvkq (vec_const_128bit_type *); > > extern unsigned constant_generates_xxspltiw (vec_const_128bit_type *); > > +extern unsigned constant_generates_xxspltidp (vec_const_128bit_type *); > > #endif /* RTX_CODE */ > > > > #ifdef TREE_CODE > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > > index be24f56eb31..8fde48cf2b3 100644 > > --- a/gcc/config/rs6000/rs6000.c > > +++ b/gcc/config/rs6000/rs6000.c > > @@ -7012,6 +7012,13 @@ output_vec_const_move (rtx *operands) > >
Ping #2: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants
Ping patch #2. | Date: Fri, 5 Nov 2021 00:10:18 -0400 | From: Michael Meissner | Subject: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants | Message-ID: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583393.html Note, I will be on-line through December 20th. I will be off-line from December 21st through January 1st. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com
Ping: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants
Ping patch. | Date: Fri, 5 Nov 2021 00:10:18 -0400 | Subject: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants | Message-ID: -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com
Re: [PATCH 4/5] Add Power10 XXSPLTIDP for vector constants
On Fri, 2021-11-05 at 00:10 -0400, Michael Meissner wrote: > Generate XXSPLTIDP for vectors on power10. > > This patch implements XXSPLTIDP support for all vector constants. The > XXSPLTIDP instruction is given a 32-bit immediate that is converted to a > vector > of two DFmode constants. The immediate is in SFmode format, so only constants > that fit as SFmode values can be loaded with XXSPLTIDP. > > The constraint (eP) added in the previous patch for XXSPLTIW is also used > for XXSPLTIDP. > ok > DImode scalar constants are not handled. This is due to the majority of > DImode > constants will be in the GPR registers. With vector registers, you have the > problem that XXSPLTIDP splats the double word into both elements of the > vector. However, if TImode is loaded with an integer constant, it wants a > full > 128-bit constant. This may be worth as adding to a todo somewhere in the code. > > SFmode and DFmode scalar constants are not handled in this patch. The > support for for those constants will be in the next patch. ok > > I have added a temporary switch (-msplat-float-constant) to control whether or > not the XXSPLTIDP instruction is generated. > > I added 2 new tests to test loading up V2DI and V2DF vector constants. > > 2021-11-05 Michael Meissner > > gcc/ > > * config/rs6000/predicates.md (easy_fp_constant): Add support for > generating XXSPLTIDP. > (vsx_prefixed_constant): Likewise. > (easy_vector_constant): Likewise. > * config/rs6000/rs6000-protos.h (constant_generates_xxspltidp): > New declaration. > * config/rs6000/rs6000.c (output_vec_const_move): Add support for > generating XXSPLTIDP. > (prefixed_xxsplti_p): Likewise. > (constant_generates_xxspltidp): New function. > * config/rs6000/rs6000.opt (-msplat-float-constant): New debug option. > > gcc/testsuite/ > > * gcc.target/powerpc/pr86731-fwrapv-longlong.c: Update insn > regex for power10. > * gcc.target/powerpc/vec-splat-constant-v2df.c: New test. > * gcc.target/powerpc/vec-splat-constant-v2di.c: New test. > --- ok > gcc/config/rs6000/predicates.md | 9 ++ > gcc/config/rs6000/rs6000-protos.h | 1 + > gcc/config/rs6000/rs6000.c| 108 ++ > gcc/config/rs6000/rs6000.opt | 4 + > .../powerpc/pr86731-fwrapv-longlong.c | 9 +- > .../powerpc/vec-splat-constant-v2df.c | 64 +++ > .../powerpc/vec-splat-constant-v2di.c | 50 > 7 files changed, 241 insertions(+), 4 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2df.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2di.c > > diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md > index ed6252bd0c4..d748b11857c 100644 > --- a/gcc/config/rs6000/predicates.md > +++ b/gcc/config/rs6000/predicates.md > @@ -610,6 +610,9 @@ (define_predicate "easy_fp_constant" > >if (constant_generates_xxspltiw (_const)) > return true; > + > + if (constant_generates_xxspltidp (_const)) > + return true; > } > >/* Otherwise consider floating point constants hard, so that the > @@ -653,6 +656,9 @@ (define_predicate "vsx_prefixed_constant" >if (constant_generates_xxspltiw (_const)) > return true; > > + if (constant_generates_xxspltidp (_const)) > +return true; > + >return false; > }) > > @@ -727,6 +733,9 @@ (define_predicate "easy_vector_constant" > > if (constant_generates_xxspltiw (_const)) > return true; > + > + if (constant_generates_xxspltidp (_const)) > + return true; > } ok > >if (TARGET_P9_VECTOR > diff --git a/gcc/config/rs6000/rs6000-protos.h > b/gcc/config/rs6000/rs6000-protos.h > index 99c6a671289..2d28df7442d 100644 > --- a/gcc/config/rs6000/rs6000-protos.h > +++ b/gcc/config/rs6000/rs6000-protos.h > @@ -253,6 +253,7 @@ extern bool vec_const_128bit_to_bytes (rtx, machine_mode, > vec_const_128bit_type *); > extern unsigned constant_generates_lxvkq (vec_const_128bit_type *); > extern unsigned constant_generates_xxspltiw (vec_const_128bit_type *); > +extern unsigned constant_generates_xxspltidp (vec_const_128bit_type *); > #endif /* RTX_CODE */ > > #ifdef TREE_CODE > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index be24f56eb31..8fde48cf2b3 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -7012,6 +7012,13 @@ output_vec_const_move (rtx *operands) > operands[2] = GEN_INT (imm); > return "xxspltiw %x0,%2"; > } > + > + imm = constant_generates_xxspltidp (_const); > + if (imm) Just a nit that the two lines could be combined into a similar form as used elsewhere as ... if (constant_generates_xxspltidp(_const)) > +
[PATCH 4/5] Add Power10 XXSPLTIDP for vector constants
Generate XXSPLTIDP for vectors on power10. This patch implements XXSPLTIDP support for all vector constants. The XXSPLTIDP instruction is given a 32-bit immediate that is converted to a vector of two DFmode constants. The immediate is in SFmode format, so only constants that fit as SFmode values can be loaded with XXSPLTIDP. The constraint (eP) added in the previous patch for XXSPLTIW is also used for XXSPLTIDP. DImode scalar constants are not handled. This is due to the majority of DImode constants will be in the GPR registers. With vector registers, you have the problem that XXSPLTIDP splats the double word into both elements of the vector. However, if TImode is loaded with an integer constant, it wants a full 128-bit constant. SFmode and DFmode scalar constants are not handled in this patch. The support for for those constants will be in the next patch. I have added a temporary switch (-msplat-float-constant) to control whether or not the XXSPLTIDP instruction is generated. I added 2 new tests to test loading up V2DI and V2DF vector constants. 2021-11-05 Michael Meissner gcc/ * config/rs6000/predicates.md (easy_fp_constant): Add support for generating XXSPLTIDP. (vsx_prefixed_constant): Likewise. (easy_vector_constant): Likewise. * config/rs6000/rs6000-protos.h (constant_generates_xxspltidp): New declaration. * config/rs6000/rs6000.c (output_vec_const_move): Add support for generating XXSPLTIDP. (prefixed_xxsplti_p): Likewise. (constant_generates_xxspltidp): New function. * config/rs6000/rs6000.opt (-msplat-float-constant): New debug option. gcc/testsuite/ * gcc.target/powerpc/pr86731-fwrapv-longlong.c: Update insn regex for power10. * gcc.target/powerpc/vec-splat-constant-v2df.c: New test. * gcc.target/powerpc/vec-splat-constant-v2di.c: New test. --- gcc/config/rs6000/predicates.md | 9 ++ gcc/config/rs6000/rs6000-protos.h | 1 + gcc/config/rs6000/rs6000.c| 108 ++ gcc/config/rs6000/rs6000.opt | 4 + .../powerpc/pr86731-fwrapv-longlong.c | 9 +- .../powerpc/vec-splat-constant-v2df.c | 64 +++ .../powerpc/vec-splat-constant-v2di.c | 50 7 files changed, 241 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2df.c create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-splat-constant-v2di.c diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index ed6252bd0c4..d748b11857c 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -610,6 +610,9 @@ (define_predicate "easy_fp_constant" if (constant_generates_xxspltiw (_const)) return true; + + if (constant_generates_xxspltidp (_const)) + return true; } /* Otherwise consider floating point constants hard, so that the @@ -653,6 +656,9 @@ (define_predicate "vsx_prefixed_constant" if (constant_generates_xxspltiw (_const)) return true; + if (constant_generates_xxspltidp (_const)) +return true; + return false; }) @@ -727,6 +733,9 @@ (define_predicate "easy_vector_constant" if (constant_generates_xxspltiw (_const)) return true; + + if (constant_generates_xxspltidp (_const)) + return true; } if (TARGET_P9_VECTOR diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index 99c6a671289..2d28df7442d 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -253,6 +253,7 @@ extern bool vec_const_128bit_to_bytes (rtx, machine_mode, vec_const_128bit_type *); extern unsigned constant_generates_lxvkq (vec_const_128bit_type *); extern unsigned constant_generates_xxspltiw (vec_const_128bit_type *); +extern unsigned constant_generates_xxspltidp (vec_const_128bit_type *); #endif /* RTX_CODE */ #ifdef TREE_CODE diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index be24f56eb31..8fde48cf2b3 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -7012,6 +7012,13 @@ output_vec_const_move (rtx *operands) operands[2] = GEN_INT (imm); return "xxspltiw %x0,%2"; } + + imm = constant_generates_xxspltidp (_const); + if (imm) + { + operands[2] = GEN_INT (imm); + return "xxspltidp %x0,%2"; + } } if (TARGET_P9_VECTOR @@ -26809,6 +26816,9 @@ prefixed_xxsplti_p (rtx_insn *insn) { if (constant_generates_xxspltiw (_const)) return true; + + if (constant_generates_xxspltidp (_const)) + return true; } return false; @@ -29014,6 +29024,104 @@ constant_generates_xxspltiw (vec_const_128bit_type *vsx_const)