]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Add pdepd and pextd
authorKelvin Nilsen <kelvin@gcc.gnu.org>
Mon, 11 May 2020 21:16:15 +0000 (16:16 -0500)
committerBill Schmidt <wschmidt@linux.ibm.com>
Mon, 11 May 2020 21:16:15 +0000 (16:16 -0500)
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.

gcc/ChangeLog
gcc/config/rs6000/rs6000-builtin.def
gcc/config/rs6000/rs6000.md
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pdep-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pdep-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pextd-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pextd-1.c [new file with mode: 0644]

index f9ce185549052b8d25d8e5870c4a2a63c13d551f..02d7452376985ceafc26496cfee0d4fbff28dfcc 100644 (file)
@@ -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.
index 39e7da5fa5069a60a07e4d52ae28ab6d1cd4dab5..4b06323a07fef3744edf77f94cf4b70859843f2e 100644 (file)
@@ -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)
index 6c9bae934d110126074b02eba0cfd72e75918a5c..4fcd6a940221cf19ca9bb05cd851d2209ffb0cfa 100644 (file)
    UNSPEC_CFUGED
    UNSPEC_CNTLZDM
    UNSPEC_CNTTZDM
+   UNSPEC_PDEPD
+   UNSPEC_PEXTD
   ])
 
 ;;
    "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")
index 104397823b0118db108432be47d407a058899fc5..9602a310cbb25b61b97ec0807daa3d582a4d6981 100644 (file)
@@ -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
 
index e3f984ea9c276475653e6bc5f27ad1c831dec1ed..74e83323e6e13cbfd0658fd6918cefc2eec6e9d3 100644 (file)
@@ -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.
diff --git a/gcc/testsuite/gcc.target/powerpc/pdep-0.c b/gcc/testsuite/gcc.target/powerpc/pdep-0.c
new file mode 100644 (file)
index 0000000..5c6afb3
--- /dev/null
@@ -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} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pdep-1.c b/gcc/testsuite/gcc.target/powerpc/pdep-1.c
new file mode 100644 (file)
index 0000000..40532ee
--- /dev/null
@@ -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;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pextd-0.c b/gcc/testsuite/gcc.target/powerpc/pextd-0.c
new file mode 100644 (file)
index 0000000..23a952d
--- /dev/null
@@ -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} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pextd-1.c b/gcc/testsuite/gcc.target/powerpc/pextd-1.c
new file mode 100644 (file)
index 0000000..814ce43
--- /dev/null
@@ -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;
+}