[PATCH,rs6000] make -mno-spe work as expected

Nathan Froyd froydnj@codesourcery.com
Thu Apr 3 20:06:00 GMT 2008


The rs6000 target option `-mno-spe' is supposed to inhibit generation of
SPE SIMD instructions.  If GCC is configured for a
powerpc-none-linux-gnuspe target, however, passing this lone option has
no effect unless `-mspe=yes' is previously passed on the command line.
(`-mspe=no' works as well, but that obviously turns SPE SIMD
instructions off too.)

This bug arises from the way options are handled and defaulting is done.
If we pass only `-mno-spe', GCC's generic option processing code sets
rs6000_spe to false.  But we eventually run code from
SUBSUBTARGET_OVERRIDE_OPTIONS in {linux,eabi}spe.h:

  if (!rs6000_explicit_options.spe) \
    rs6000_spe = 1; \

Since GCC's option processing code did not set
rs6000_explicit_options.spe, rs6000_spe is always set--against the
user's wishes.  But if we pass `-mspe=yes -mno-spe', the rs6000 backend
gets to process the first option and sets rs6000_explicit_options.spe,
so that the setting of rs6000_spe to false by the second option is
honored.

The solution is to move the processing of -m{no-,}spe into the rs6000
backend so that it can set rs6000_explicit_options.spe appropriately.

Bootstrapped and regtested on powerpc-none-linux-gnuspe.  OK to commit?

-Nathan

2008-04-03  Nathan Froyd  <froydnj@codesourcery.com>

	* config/rs6000/rs6000.opt (mspe): Remove Var property.
	* config/rs6000/rs6000.h (rs6000_spe): Declare.
	* config/rs6000/rs6000.c (rs6000_spe): New variable.
	(rs6000_handle_option): Handle OPT_mspe.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 133871)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -174,6 +174,9 @@ int rs6000_ieeequad;
 /* Nonzero to use AltiVec ABI.  */
 int rs6000_altivec_abi;
 
+/* Nonzero if we want SPE SIMD instructions.  */
+int rs6000_spe;
+
 /* Nonzero if we want SPE ABI extensions.  */
 int rs6000_spe_abi;
 
@@ -2182,6 +2185,11 @@ rs6000_handle_option (size_t code, const
       rs6000_parse_yes_no_option ("isel", arg, &(rs6000_isel));
       break;
 
+    case OPT_mspe:
+      rs6000_explicit_options.spe = true;
+      rs6000_spe = value;
+      break;
+
     case OPT_mspe_:
       rs6000_explicit_options.spe = true;
       rs6000_parse_yes_no_option ("spe", arg, &(rs6000_spe));
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 133871)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -367,6 +367,7 @@ extern int rs6000_long_double_type_size;
 extern int rs6000_ieeequad;
 extern int rs6000_altivec_abi;
 extern int rs6000_spe_abi;
+extern int rs6000_spe;
 extern int rs6000_float_gprs;
 extern int rs6000_alignment_flags;
 extern const char *rs6000_sched_insert_nops_str;
Index: gcc/config/rs6000/rs6000.opt
===================================================================
--- gcc/config/rs6000/rs6000.opt	(revision 133871)
+++ gcc/config/rs6000/rs6000.opt	(working copy)
@@ -198,7 +198,7 @@ Target RejectNegative Joined
 -misel=yes/no	Deprecated option.  Use -misel/-mno-isel instead
 
 mspe
-Target Var(rs6000_spe)
+Target
 Generate SPE SIMD instructions on E500
 
 mpaired



More information about the Gcc-patches mailing list