On Thu, Dec 08, 2011 at 04:26:07PM -0500, Michael Meissner wrote: > These patches add support for #pragma GCC target("...") on the powerpc to > change the default macros defined like tha x86 does (and the powerpc did for > the target attribute). When adding support for changing macros on the target > attribute, I forgot to enable the code for #pragma as well. > > Also, the recip-5.c test has been failing on systems that don't support VSX, > such as Darwin. The test itself should not have been run on those system, as > I > forgot to add the standard lines for VSX patches to the test. In addition, > when reporting the bug, the compiler segfaulted. This was due to the expand > builtin function returning NULL or const0_rtx (depending on the error), and > the > higher level code was not expecting NULL. For this case, I did a normal > expand_call operation. > > I did make boostrap and there were no regressions. Is it ok to install these > patches? > > [gcc] > 2011-12-08 Michael Meissner <meiss...@the-meissners.org> > > * config/rs6000/rs6000.c (altivec_expand_builtin): Call > expand_call to return a valid funciton instead of return > cosnt0_rtx/NULL_RTX if there was an error with the builtin. > (altivec_expand_ld_builtin): Ditto. > (rs6000_inner_target_options): If VSX is selected as a target > attribute or pragma, enable ALTIVEC also. > (rs6000_pragma_target_parse): Call rs6000_option_override_internal > to do all of the standard processing when switching options, > including redefining appropriate macros. > > [gcc/testsuite] > 2011-12-08 Michael Meissner <meiss...@the-meissners.org> > > * gcc.target/powerpc/recip-5.c: Disable running on any system that > does not support VSX. > > -- > Michael Meissner, IBM > 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA > meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899
Sigh. Patch attached. -- Michael Meissner, IBM 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899
Index: gcc/testsuite/gcc.target/powerpc/recip-5.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/recip-5.c (revision 182134) +++ gcc/testsuite/gcc.target/powerpc/recip-5.c (working copy) @@ -1,5 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ -/* { dg-require-effective-target powerpc_fprs } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ /* { dg-options "-O3 -ftree-vectorize -mrecip=all -ffast-math -mcpu=power7 -fno-unroll-loops" } */ /* { dg-final { scan-assembler-times "xvredp" 4 } } */ /* { dg-final { scan-assembler-times "xvresp" 5 } } */ Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 182134) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -10578,7 +10578,9 @@ altivec_expand_builtin (tree exp, rtx ta { *expandedp = true; error ("unresolved overload for Altivec builtin %qF", fndecl); - return const0_rtx; + + /* Given it is invalid, just generate a normal call. */ + return expand_call (exp, target, false); } target = altivec_expand_ld_builtin (exp, target, expandedp); @@ -11306,7 +11308,9 @@ rs6000_expand_builtin (tree exp, rtx tar if (!func_valid_p) { rs6000_invalid_builtin (fcode); - return NULL_RTX; + + /* Given it is invalid, just generate a normal call. */ + return expand_call (exp, target, ignore); } switch (fcode) @@ -26789,6 +26793,11 @@ rs6000_inner_target_options (tree args, error_p = false; target_flags_explicit |= mask; + /* VSX needs altivec, so -mvsx automagically sets + altivec. */ + if (mask == MASK_VSX && !invert) + mask |= MASK_ALTIVEC; + if (rs6000_opt_masks[i].invert) invert = !invert; @@ -27001,7 +27010,6 @@ rs6000_pragma_target_parse (tree args, t struct cl_target_option *prev_opt, *cur_opt; unsigned prev_bumask, cur_bumask, diff_bumask; int prev_flags, cur_flags, diff_flags; - bool ret; if (TARGET_DEBUG_TARGET) { @@ -27023,7 +27031,6 @@ rs6000_pragma_target_parse (tree args, t if (! args) { - ret = true; cur_tree = ((pop_target) ? pop_target : target_option_default_node); @@ -27033,13 +27040,13 @@ rs6000_pragma_target_parse (tree args, t else { rs6000_cpu_index = rs6000_tune_index = -1; - ret = rs6000_inner_target_options (args, false); - cur_tree = build_target_option_node (); - - if (!cur_tree) + if (!rs6000_inner_target_options (args, false) + || !rs6000_option_override_internal (false) + || (cur_tree = build_target_option_node ()) == NULL_TREE) { if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET) - fprintf (stderr, "build_target_option_node returned NULL\n"); + fprintf (stderr, "invalid pragma\n"); + return false; } } @@ -27075,7 +27082,7 @@ rs6000_pragma_target_parse (tree args, t } } - return ret; + return true; }