Hi! On Wed, Jul 08, 2020 at 11:02:45PM -0500, Peter Bergner wrote: > PR96125 shows a bug when we try to use an MMA built-in within a function > that uses #pragma target/attribute target to enable power10 code generation > and the -mcpu=<CPU> command line option is pre-power10. > > The problem is that we only initialize built-ins once, fairly early, when > the command line options are in force. If the -mcpu=<CPU> is pre-power10, > then we fail to initialize the MMA built-ins at all and so they are not > available to call in a #pragma target/attribute target function. > > The patch below basically always (on server type cpus) initializes the MMA > built-ins so we can use them in #pragma target/attribute target functions. > The patch below fixes the bug and is currently in the middle of testing. > > Is this ok for trunk assuming the bootstrap and regression testing > show no regressions? > > This also affects GCC10, so I'd like to backport this before the release. > Ok there too after it sits on trunk a day or two?
> gcc/ > PR target/96125 > * config/rs6000/rs6000-call.c (rs6000_init_builtins): Define the MMA > specific types __vector_quad and __vector_pair, and initialize the > MMA built-ins if TARGET_EXTRA_BUILTINS is set. > (mma_init_builtins): Don't test for mask set in rs6000_builtin_mask. > Remove now unneeded mask variable. > * config/rs6000/rs6000.c (rs6000_option_override_internal): Add the > OPTION_MASK_MMA flag for power10 if not already set. > > gcc/testsuite/ > PR target/96125 > * gcc.target/powerpc/pr96125.c: New test. Okay for trunk and 10 (but see test nit below). Thanks! > - /* Create Altivec and VSX builtins on machines with at least the > + /* Create Altivec, VSX and MMA builtins on machines with at least the > general purpose extensions (970 and newer) to allow the use of > the target attribute. */ > if (TARGET_EXTRA_BUILTINS) > - altivec_init_builtins (); > - if (TARGET_MMA) > - mma_init_builtins (); > + { > + altivec_init_builtins (); > + mma_init_builtins (); > + } > if (TARGET_HTM) > htm_init_builtins (); So maybe we should just do all builtins always? > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr96125.c > @@ -0,0 +1,47 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target powerpc_vsx_ok } */ > +/* { dg-options "-mdejagnu-cpu=power8 -O2" } */ powerpc_vsx_ok is not the right test for -mcpu=power8 (it means p7). Usually powerpc_p8vector_ok is used... not a great situation, but :-) Segher