This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] __attribute__((inline_everything)) 2nd try


Hi!

I finally got it working - apart from automatically setting
__attribute__((noinline)), if __attribute__((inline_everything)) is
specified - how am I supposed to do this?

The patch should have no effect on people using the attribute, but
results in 20% performance increase if used on the Kernels of my
scientific application (which is based on POOMA).

I'm no going to figure out where the rest of the performance increase
went (originally got 33% with carefully placed always_inlines and
the artificial min-inline-insns cutoff removed).

Suggestions?

Patch is against 3.3, but will probably apply to mainline, too.
Tested by bootstrapping on ix86 and my scientific code.

Richard.


Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.18.4.1
diff -u -u -r1.18.4.1 c-objc-common.c
--- c-objc-common.c	2 May 2003 19:52:02 -0000	1.18.4.1
+++ c-objc-common.c	14 May 2003 07:22:52 -0000
@@ -156,6 +156,7 @@
   return NULL_TREE;
 }

+extern int inline_everything;
 int
 c_cannot_inline_tree_fn (fnp)
      tree *fnp;
@@ -164,6 +165,7 @@
   tree t;

   if (flag_really_no_inline
+      && ! inline_everything
       && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
     return 1;

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.38.2.8
diff -u -u -r1.38.2.8 tree-inline.c
--- tree-inline.c	2 May 2003 19:52:01 -0000	1.38.2.8
+++ tree-inline.c	14 May 2003 07:22:53 -0000
@@ -51,6 +51,7 @@
    candidates.  */

 int flag_inline_trees = 0;
+int inline_everything = 0;

 /* To Do:

@@ -938,7 +939,7 @@

   /* If we've already decided this function shouldn't be inlined,
      there's no need to check again.  */
-  if (DECL_UNINLINABLE (fn))
+  if (! inline_everything && DECL_UNINLINABLE (fn))
     return 0;

   /* Assume it is not inlinable.  */
@@ -962,7 +963,7 @@
      front-end that must set DECL_INLINE in this case, because
      dwarf2out loses if a function is inlined that doesn't have
      DECL_INLINE set.  */
-  else if (! DECL_INLINE (fn))
+  else if (! inline_everything && ! DECL_INLINE (fn))
     ;
 #ifdef INLINER_FOR_JAVA
   /* Synchronized methods can't be inlined.  This is a bug.  */
@@ -972,8 +973,9 @@
   /* We can't inline functions that are too big.  Only allow a single
      function to be of MAX_INLINE_INSNS_SINGLE size.  Make special
      allowance for extern inline functions, though.  */
-  else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
-	   && currfn_insns > max_inline_insns_single)
+  else if (! inline_everything
+	   && currfn_insns > max_inline_insns_single
+           && ! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn))
     ;
   /* We can't inline functions that call __builtin_longjmp at all.
      The non-local goto machenery really requires the destination
@@ -1000,10 +1002,14 @@
   /* Squirrel away the result so that we don't have to check again.  */
   DECL_UNINLINABLE (fn) = ! inlinable;

+  if (! inlinable)
+    return 0;
+
   /* In case we don't disregard the inlining limits and we basically
      can inline this function, investigate further.  */
-  if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
-      && inlinable)
+  if (! inline_everything
+      && inlinable
+      && ! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn))
     {
       int sum_insns = (id ? id->inlined_stmts : 0) * INSNS_PER_STMT
 		     + currfn_insns;
@@ -1011,7 +1017,7 @@
          limit by a huge factor (128), we just say no. Should not happen
          in real life.  */
       if (sum_insns > MAX_INLINE_INSNS * 128)
-	 inlinable = 0;
+        inlinable = 0;
       /* If we did not hit the extreme limit, we use a linear function
          with slope -1/MAX_INLINE_SLOPE to exceedingly decrease the
          allowable size. We always allow a size of MIN_INLINE_INSNS
@@ -1027,12 +1033,12 @@
     }

   if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))
-    inlinable = 0;
+    return 0;

   /* If we don't have the function body available, we can't inline
      it.  */
   if (! DECL_SAVED_TREE (fn))
-    inlinable = 0;
+    return 0;

   /* Check again, language hooks may have modified it.  */
   if (! inlinable || DECL_UNINLINABLE (fn))
@@ -1171,7 +1177,7 @@
      inlining.  */
   if (!inlinable_function_p (fn, id))
     {
-      if (warn_inline && DECL_INLINE (fn))
+      if (warn_inline && (DECL_INLINE (fn) || inline_everything))
 	{
 	  warning_with_decl (fn, "inlining failed in call to `%s'");
 	  warning ("called from here");
@@ -1468,11 +1474,17 @@
      real inlining is represented in ID.FNS.  */
   id.first_inlined_fn = VARRAY_ACTIVE_SIZE (id.fns);

+  if (lookup_attribute ("inline_everything", DECL_ATTRIBUTES (fn)) != NULL)
+    inline_everything++;
+
   /* Replace all calls to inline functions with the bodies of those
      functions.  */
   id.tree_pruner = htab_create (37, htab_hash_pointer,
 				htab_eq_pointer, NULL);
   expand_calls_inline (&DECL_SAVED_TREE (fn), &id);
+
+  if (lookup_attribute ("inline_everything", DECL_ATTRIBUTES (fn)) != NULL)
+    inline_everything--;

   /* Clean up.  */
   htab_delete (id.tree_pruner);
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.393.2.3
diff -u -u -r1.393.2.3 c-common.c
--- c-common.c	9 Mar 2003 19:31:11 -0000	1.393.2.3
+++ c-common.c	14 May 2003 07:22:56 -0000
@@ -812,6 +812,8 @@
 			      handle_noinline_attribute },
   { "always_inline",          0, 0, true,  false, false,
 			      handle_always_inline_attribute },
+  { "inline_everything",      0, 0, true,  false, false,
+			      NULL },
   { "used",                   0, 0, true,  false, false,
 			      handle_used_attribute },
   { "unused",                 0, 0, false, false, false,
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.307.2.3
diff -u -u -r1.307.2.3 tree.c
--- cp/tree.c	15 Apr 2003 00:35:53 -0000	1.307.2.3
+++ cp/tree.c	14 May 2003 07:22:57 -0000
@@ -2232,6 +2232,7 @@
 /* Decide whether there are language-specific reasons to not inline a
    function as a tree.  */

+extern int inline_everything;
 int
 cp_cannot_inline_tree_fn (fnp)
      tree *fnp;
@@ -2239,6 +2240,7 @@
   tree fn = *fnp;

   if (flag_really_no_inline
+      && ! inline_everything
       && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
     return 1;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]