Hi!

On Thu, Jun 04, 2020 at 10:11:29PM -0400, Michael Meissner wrote:
> This patch adds support for the two new HWCAP2 fields used by the
> __builtin_cpu_supports function.  It adds support in the target_clones
> attribute for -mcpu=future.

> --- a/gcc/config/rs6000/rs6000-call.c
> +++ b/gcc/config/rs6000/rs6000-call.c
> @@ -172,7 +172,9 @@ static const struct
>    { "arch_3_00",     PPC_FEATURE2_ARCH_3_00,         1 },
>    { "ieee128",               PPC_FEATURE2_HAS_IEEE128,       1 },
>    { "darn",          PPC_FEATURE2_DARN,              1 },
> -  { "scv",           PPC_FEATURE2_SCV,               1 }
> +  { "scv",           PPC_FEATURE2_SCV,               1 },
> +  { "arch_3_1",              PPC_FEATURE2_ARCH_3_1,          1 },
> +  { "mma",           PPC_FEATURE2_MMA,               1 },
>  };

Does the trailing comma not warn?  Okay if not.

> diff --git a/gcc/testsuite/gcc.target/powerpc/clone3.c 
> b/gcc/testsuite/gcc.target/powerpc/clone3.c
> new file mode 100644
> index 0000000..93ee41d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/clone3.c
> @@ -0,0 +1,33 @@
> +/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
> +/* { dg-options "-mdejagnu-cpu=power8 -O2" } */
> +/* { dg-require-effective-target powerpc_pcrel } */
> +/* { dg-require-effective-target ppc_cpu_supports_hw } */
> +
> +/* Power9 (aka, ISA 3.0) has a MODSD instruction to do modulus, while Power8
> +   (aka, ISA 2.07) has to do modulus with divide and multiply.  Make sure
> +   both clone functions are generated.
> +
> +   FUTURE has pc-relative instructions to access static values, while earlier
> +   systems used TOC addressing.
> +
> +   Restrict ourselves to Linux, since IFUNC might not be supported in other
> +   operating systems.  */
> +
> +static long s;
> +long *p = &s;
> +
> +__attribute__((target_clones("cpu=future,cpu=power9,default")))
> +long mod_func (long a, long b)
> +{
> +  return (a % b) + s;
> +}
> +
> +long mod_func_or (long a, long b, long c)
> +{
> +  return mod_func (a, b) | c;
> +}
> +
> +/* { dg-final { scan-assembler-times {\mdivd\M}  1 } } */
> +/* { dg-final { scan-assembler-times {\mmulld\M} 1 } } */
> +/* { dg-final { scan-assembler-times {\mmodsd\M} 2 } } */
> +/* { dg-final { scan-assembler-times {\mpld\M}   1 } } */

This needs some more documentation what it tests, and how.

And/or maybe the  dg-require-effective-target powerpc_pcrel  shouldn't
be there?

Okay for trunk with those two things cleared up.  Thanks!


Segher

Reply via email to