This is the mail archive of the gcc@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]

Re: std::pow implementation


Op wo 30-07-2003, om 14:22 schreef Richard Guenther:
> On 30 Jul 2003, Gabriel Dos Reis wrote:
> 
> > Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
> >
> > | Of course being able to hint the compiler some more can be useful to
> > | overcome weakness in the compilers inlining decision implementation as
> > | that never will be perfect.
> >
> > It takes first abandoning the idea that the compiler always knows
> > better than the programmer and the programmer's use of "inline" is
> > most of the time nonsensical.  The programmer does provide hint.  The
> > compiler choses not to listen.
> 
> Well, the point is you question that inline should be a hint, but take it
> as the same as __attribute__((always_inline)) is defined. The compiler is
> free to ignore hints if it thinks the hint is against the task it is
> performing (take f.i. a inline declared modestly sized function when
> compiling with -Os).

No, always_inline also implies inlining functions that call alloca, so 
it's a bit stronger than that.

The attached patch makes C++ ignore inline limits if the function was
declared with "inline".  Maybe you can try and see what it does for you?

> I'd argue for the inline keyword makeing the compiler think twice before
> not inlining a function and -finline-functions on by default (if inline is
> a hint to inline, why should no inline force the compiler not to inline?).

That could be done by setting max-inline-insns-single to a larger value
for C++.  This has been discussed many times and your numbers show it
would help, but at an unacceptable cost of compiler speed.  IIRC a lot
of the slowdown was in expand, so with tree-ssa we could give this
another try (assuming tree-inline can clean up a lot of cruft before
expanding...).

Gr.
Steven


Index: cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.57
diff -c -3 -p -r1.57 cp-lang.c
*** cp-lang.c	22 Jul 2003 23:30:13 -0000	1.57
--- cp-lang.c	30 Jul 2003 12:49:58 -0000
*************** static bool cxx_warn_unused_global_decl 
*** 38,43 ****
--- 38,44 ----
  static tree cp_expr_size (tree);
  static size_t cp_tree_size (enum tree_code);
  static bool cp_var_mod_type_p (tree);
+ static int cp_disregard_inline_limits (tree fn);
  
  #undef LANG_HOOKS_NAME
  #define LANG_HOOKS_NAME "GNU C++"
*************** static bool cp_var_mod_type_p (tree);
*** 124,129 ****
--- 125,133 ----
  #undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
  #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
    cp_cannot_inline_tree_fn
+ #undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS
+ #define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
+   cp_disregard_inline_limits
  #undef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS
  #define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS \
    cp_add_pending_fn_decls
*************** cp_var_mod_type_p (tree type)
*** 370,375 ****
--- 374,386 ----
  
    /* All other types are not variably modified.  */
    return false;
+ }
+ 
+ /* Force inlining of functions declared inline.  */
+ int
+ cp_disregard_inline_limits (tree fn)
+ {
+   return DECL_DECLARED_INLINE_P (fn);
  }
  
  /* Stub routine to tell people that this doesn't work yet.  */

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