Patch to -Os

Marc Lehmann pcg@goof.com
Sat Jan 31 12:09:00 GMT 1998


The new -Os switch is a wonderful idea (for example it let me remove the
-fopt-size option from pgcc ;)

anyway, here's a small patch that might make more sense than to disable
-finline-functions altogether with -Os.

The idea is that a function call is at least 1 instruction (call) plus 1.5
instructions per argument (well, constants are one or two insns, simple
variables are one or two insns..), so doing the inline with small functions
might be even better than calling them, since the actual call needs more
instructions (there _are_ such functions!)

The patch re-enables -finline-functions with -Os and sets
INTEGRATE_THRESHOLD to a small value when -Os is specified.

Another (maybe much better!) approach would be to do this for
all architectures, i.e. leaving flagh_inline_functions alone
and just making the default for INTEGRATE_THRESHOLD smaller
(although architectures that aslready define INTEGRATE_THRESHOLD
need a change, then).

any comments?


1998-01-31  Marc Lehmann <pcg@goof.com>
	
	* config/i386/i386.h (INTEGRATE_THRESHOLD): New define.
	* config/i386/i386.c (optimization_options): Enable
	flag_inline_functions even when -Os is specified.

--- gcc/config/i386/i386.c.orig	Sat Jan 31 20:42:21 1998
+++ gcc/config/i386/i386.c	Sat Jan 31 20:46:32 1998
@@ -420,6 +420,9 @@
   if (level > 1)
     flag_schedule_insns = 0;
 #endif
+  
+  if (level > 2)
+    flag_inline_functions = 1;
 }
 
 /* Sign-extend a 16-bit constant */
--- gcc/config/i386/i386.h.orig	Sat Jan 31 20:42:15 1998
+++ gcc/config/i386/i386.h	Sat Jan 31 20:45:19 1998
@@ -1855,6 +1855,14 @@
    is a byte address (for indexing purposes)
    so give the MEM rtx a byte's mode.  */
 #define FUNCTION_MODE QImode
+
+/* A C expression for the maximum number of instructions above which
+   the function DECL should not be inlined.  DECL is a
+   'FUNCTION_DECL' node.  */
+
+#define INTEGRATE_THRESHOLD(DECL) (optimize_size \
+  ? (1 + (3 * list_length (DECL_ARGUMENTS (DECL) / 2))) \
+  : (8 * (8 + list_length (DECL_ARGUMENTS (DECL)))))
 
 /* A part of a C `switch' statement that describes the relative costs
    of constant RTL expressions.  It must contain `case' labels for




More information about the Gcc mailing list