rs6000: Add pdepd and pextd
Add scalar instructions for parallel bit deposit and extract, with built-in function support. [gcc] 2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org> * config/rs6000/rs6000-builtin.def (__builtin_pdepd): New built-in function. (__builtin_pextd): Likewise. * config/rs6000/rs6000.md (UNSPEC_PDEPD): New constant. (UNSPEC_PEXTD): Likewise. (pdepd): New insn. (pextd): Likewise. * doc/extend.texi (Basic PowerPC Built-in Functions Available for a Future Architecture): Add descriptions of __builtin_pdepd and __builtin_pextd functions. [gcc/testsuite] 2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org> * gcc.target/powerpc/pdep-0.c: New. * gcc.target/powerpc/pdep-1.c: New. * gcc.target/powerpc/pextd-0.c: New. * gcc.target/powerpc/pextd-1.c: New.
This commit is contained in:
parent
25bf7d32c3
commit
2202299c2a
9 changed files with 253 additions and 0 deletions
|
@ -1,3 +1,16 @@
|
|||
2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org>
|
||||
|
||||
* config/rs6000/rs6000-builtin.def (__builtin_pdepd): New built-in
|
||||
function.
|
||||
(__builtin_pextd): Likewise.
|
||||
* config/rs6000/rs6000.md (UNSPEC_PDEPD): New constant.
|
||||
(UNSPEC_PEXTD): Likewise.
|
||||
(pdepd): New insn.
|
||||
(pextd): Likewise.
|
||||
* doc/extend.texi (Basic PowerPC Built-in Functions Available for
|
||||
a Future Architecture): Add descriptions of __builtin_pdepd and
|
||||
__builtin_pextd functions.
|
||||
|
||||
2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org>
|
||||
|
||||
* config/rs6000/altivec.h (vec_clrl): New #define.
|
||||
|
|
|
@ -2577,6 +2577,8 @@ BU_P9_OVERLOAD_2 (CMPEQB, "byte_in_set")
|
|||
BU_FUTURE_MISC_2 (CFUGED, "cfuged", CONST, cfuged)
|
||||
BU_FUTURE_MISC_2 (CNTLZDM, "cntlzdm", CONST, cntlzdm)
|
||||
BU_FUTURE_MISC_2 (CNTTZDM, "cnttzdm", CONST, cnttzdm)
|
||||
BU_FUTURE_MISC_2 (PDEPD, "pdepd", CONST, pdepd)
|
||||
BU_FUTURE_MISC_2 (PEXTD, "pextd", CONST, pextd)
|
||||
|
||||
/* Future architecture vector built-ins. */
|
||||
BU_FUTURE_V_2 (VCLRLB, "vclrlb", CONST, vclrlb)
|
||||
|
|
|
@ -151,6 +151,8 @@
|
|||
UNSPEC_CFUGED
|
||||
UNSPEC_CNTLZDM
|
||||
UNSPEC_CNTTZDM
|
||||
UNSPEC_PDEPD
|
||||
UNSPEC_PEXTD
|
||||
])
|
||||
|
||||
;;
|
||||
|
@ -2483,6 +2485,24 @@
|
|||
"cnttzdm %0,%1,%2"
|
||||
[(set_attr "type" "integer")])
|
||||
|
||||
(define_insn "pdepd"
|
||||
[(set (match_operand:DI 0 "register_operand" "=r")
|
||||
(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "r")
|
||||
(match_operand:DI 2 "gpc_reg_operand" "r")]
|
||||
UNSPEC_PDEPD))]
|
||||
"TARGET_FUTURE && TARGET_POWERPC64"
|
||||
"pdepd %0,%1,%2"
|
||||
[(set_attr "type" "integer")])
|
||||
|
||||
(define_insn "pextd"
|
||||
[(set (match_operand:DI 0 "register_operand" "=r")
|
||||
(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "r")
|
||||
(match_operand:DI 2 "gpc_reg_operand" "r")]
|
||||
UNSPEC_PEXTD))]
|
||||
"TARGET_FUTURE && TARGET_POWERPC64"
|
||||
"pextd %0,%1,%2"
|
||||
[(set_attr "type" "integer")])
|
||||
|
||||
(define_insn "cmpb<mode>3"
|
||||
[(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
|
||||
(unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")
|
||||
|
|
|
@ -17572,6 +17572,22 @@ Perform a 64-bit count trailing zeros operation under mask, as if
|
|||
implemented by the future @code{cnttzdm} instruction.
|
||||
@findex __builtin_cnttzdm
|
||||
|
||||
@smallexample
|
||||
@exdent unsigned long long int
|
||||
@exdent __builtin_pdepd (unsigned long long int, unsigned long long int)
|
||||
@end smallexample
|
||||
Perform a 64-bit parallel bits deposit operation, as if implemented by the
|
||||
Future @code{pdepd} instruction.
|
||||
@findex __builtin_pdepd
|
||||
|
||||
@smallexample
|
||||
@exdent unsigned long long int
|
||||
@exdent __builtin_pextd (unsigned long long int, unsigned long long int)
|
||||
@end smallexample
|
||||
Perform a 64-bit parallel bits extract operation, as if implemented by the
|
||||
Future @code{pextd} instruction.
|
||||
@findex __builtin_pextd
|
||||
|
||||
@node PowerPC AltiVec/VSX Built-in Functions
|
||||
@subsection PowerPC AltiVec/VSX Built-in Functions
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org>
|
||||
|
||||
* gcc.target/powerpc/pdep-0.c: New.
|
||||
* gcc.target/powerpc/pdep-1.c: New.
|
||||
* gcc.target/powerpc/pextd-0.c: New.
|
||||
* gcc.target/powerpc/pextd-1.c: New.
|
||||
|
||||
2020-05-11 Kelvin Nilsen <kelvin@gcc.gnu.org>
|
||||
|
||||
* gcc.target/powerpc/vec-clrl-0.c: New.
|
||||
|
|
48
gcc/testsuite/gcc.target/powerpc/pdep-0.c
Normal file
48
gcc/testsuite/gcc.target/powerpc/pdep-0.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target powerpc64 } */
|
||||
/* { dg-options "-mcpu=future" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
unsigned long long int
|
||||
do_pdepd (unsigned long long int source, unsigned long long int mask) {
|
||||
return __builtin_pdepd (source, mask);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
unsigned long long int sources [4], masks [4];
|
||||
unsigned long long int results [4][4] = {
|
||||
/* sources [0] with each of masks [0..3] */
|
||||
{ 0x7e3c0000ll, 0x00007e3cll, 0x070e030cll, 0x70e030c0ll },
|
||||
/* sources [1] with each of masks [0..3] */
|
||||
{ 0xa5f00000ll, 0x0000a5f0ll, 0x0a050f00ll, 0xa050f000ll },
|
||||
/* sources [2] with each of masks [0..3] */
|
||||
{ 0xf07e0000ll, 0x0000f07ell, 0x0f00070ell, 0xf00070e0ll },
|
||||
/* sources [3] with each of masks [0..3] */
|
||||
{ 0xe7c30000ll, 0x0000e7c3ll, 0x0e070c03ll, 0xe070c030ll },
|
||||
};
|
||||
|
||||
sources[0] = 0xa5f07e3cll;
|
||||
sources[1] = 0x7e3ca5f0ll;
|
||||
sources[2] = 0x3ca5f07ell;
|
||||
sources[3] = 0x5a0fe7c3ll;
|
||||
|
||||
masks[0] = 0xffff0000ll;
|
||||
masks[1] = 0x0000ffffll;
|
||||
masks[2] = 0x0f0f0f0fll;
|
||||
masks[3] = 0xf0f0f0f0ll;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (do_pdepd (sources[i], masks[j]) != results [i][j])
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler {\mpdepd\M} } } */
|
48
gcc/testsuite/gcc.target/powerpc/pdep-1.c
Normal file
48
gcc/testsuite/gcc.target/powerpc/pdep-1.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target powerpc_future_hw } */
|
||||
/* { dg-require-effective-target powerpc64 } */
|
||||
/* { dg-options "-mcpu=future" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
unsigned long long int
|
||||
do_pdepd (unsigned long long int source, unsigned long long int mask) {
|
||||
return __builtin_pdepd (source, mask);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
unsigned long long int sources [4], masks [4];
|
||||
unsigned long long int results [4][4] = {
|
||||
/* sources [0] with each of masks [0..3] */
|
||||
{ 0x7e3c0000ll, 0x00007e3cll, 0x070e030cll, 0x70e030c0ll },
|
||||
/* sources [1] with each of masks [0..3] */
|
||||
{ 0xa5f00000ll, 0x0000a5f0ll, 0x0a050f00ll, 0xa050f000ll },
|
||||
/* sources [2] with each of masks [0..3] */
|
||||
{ 0xf07e0000ll, 0x0000f07ell, 0x0f00070ell, 0xf00070e0ll },
|
||||
/* sources [3] with each of masks [0..3] */
|
||||
{ 0xe7c30000ll, 0x0000e7c3ll, 0x0e070c03ll, 0xe070c030ll },
|
||||
};
|
||||
|
||||
sources[0] = 0xa5f07e3cll;
|
||||
sources[1] = 0x7e3ca5f0ll;
|
||||
sources[2] = 0x3ca5f07ell;
|
||||
sources[3] = 0x5a0fe7c3ll;
|
||||
|
||||
masks[0] = 0xffff0000ll;
|
||||
masks[1] = 0x0000ffffll;
|
||||
masks[2] = 0x0f0f0f0fll;
|
||||
masks[3] = 0xf0f0f0f0ll;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (do_pdepd (sources[i], masks[j]) != results [i][j])
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
50
gcc/testsuite/gcc.target/powerpc/pextd-0.c
Normal file
50
gcc/testsuite/gcc.target/powerpc/pextd-0.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target powerpc64 } */
|
||||
/* { dg-options "-mcpu=future" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
unsigned long long int
|
||||
do_pextd (unsigned long long int source, unsigned long long int mask) {
|
||||
return __builtin_pextd (source, mask);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
unsigned long long int sources [4], masks [4];
|
||||
unsigned long long int results [4][4] = {
|
||||
/* sources [0] with each of masks [0..3] */
|
||||
{ 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll },
|
||||
/* sources [1] with each of masks [0..3] */
|
||||
{ 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll },
|
||||
/* sources [2] with each of masks [0..3] */
|
||||
{ 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll },
|
||||
/* sources [3] with each of masks [0..3] */
|
||||
{ 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll },
|
||||
};
|
||||
|
||||
sources[0] = 0xa5f07e3cll;
|
||||
sources[1] = 0x7e3ca5f0ll;
|
||||
sources[2] = 0x3ca5f07ell;
|
||||
sources[3] = 0x5a0fe7c3ll;
|
||||
|
||||
masks[0] = 0xffff0000ll;
|
||||
masks[1] = 0x0000ffffll;
|
||||
masks[2] = 0x0f0f0f0fll;
|
||||
masks[3] = 0xf0f0f0f0ll;
|
||||
|
||||
unsigned long long int result;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (do_pextd (sources[i], masks[j]) != results [i][j])
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler {\mpextd\M} } } */
|
49
gcc/testsuite/gcc.target/powerpc/pextd-1.c
Normal file
49
gcc/testsuite/gcc.target/powerpc/pextd-1.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target powerpc_future_hw } */
|
||||
/* { dg-require-effective-target powerpc64 } */
|
||||
/* { dg-options "-mcpu=future" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
unsigned long long int
|
||||
do_pextd (unsigned long long int source, unsigned long long int mask) {
|
||||
return __builtin_pextd (source, mask);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
unsigned long long int sources [4], masks [4];
|
||||
unsigned long long int results [4][4] = {
|
||||
/* sources [0] with each of masks [0..3] */
|
||||
{ 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll },
|
||||
/* sources [1] with each of masks [0..3] */
|
||||
{ 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll },
|
||||
/* sources [2] with each of masks [0..3] */
|
||||
{ 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll },
|
||||
/* sources [3] with each of masks [0..3] */
|
||||
{ 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll },
|
||||
};
|
||||
|
||||
sources[0] = 0xa5f07e3cll;
|
||||
sources[1] = 0x7e3ca5f0ll;
|
||||
sources[2] = 0x3ca5f07ell;
|
||||
sources[3] = 0x5a0fe7c3ll;
|
||||
|
||||
masks[0] = 0xffff0000ll;
|
||||
masks[1] = 0x0000ffffll;
|
||||
masks[2] = 0x0f0f0f0fll;
|
||||
masks[3] = 0xf0f0f0f0ll;
|
||||
|
||||
unsigned long long int result;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (do_pextd (sources[i], masks[j]) != results [i][j])
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue