Commit 4d4b8cb9 by Jan Hubicka Committed by Jan Hubicka

re PR middle-end/29478 (optimization generates warning for casts)


	* gcc.dg/tree-ssa/loadpre8.c: Disable inlining.
	* gcc.dg/tree-ssa/pr27236.c: Likewise.
	* gcc.dg/tree-ssa/predcom-1.c: Likewise.
	* gcc.dg/tree-ssa/predcom-2.c: Likewise.
	* gcc.dg/tree-ssa/flatten-2.c: Avoid overactive tail call ellim.
	* gcc.dg/tree-ssa/loadpre5.c: Likewise.
	* gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c:
	Likewise.
	* invoke.texi (-finline-small-functions): Document.
	* ipa-inline.c (cgraph_default_inline_p): Do not use DECL_INLINE
	when deciding what is inlinable.
	(cgraph_decide_recursive_inlining): Handle flag_inline_functions.
	(cgraph_decide_inlining_of_small_function): Handle new flags.
	(cgraph_decide_inlining_incrementally): Likewise.
	* opts.c (decode_options): Enable flag_inline_small_functions at -O2
	* common.opt (finline-small-functions): New.
	* Makefile.in (build/gengtype.o-warn): Work around PR29478

From-SVN: r128092
parent 4c5bae34
2007-09-04 Jan Hubicka <jh@suse.cz>
* invoke.texi (-finline-small-functions): Document.
* ipa-inline.c (cgraph_default_inline_p): Do not use DECL_INLINE
when deciding what is inlinable.
(cgraph_decide_recursive_inlining): Handle flag_inline_functions.
(cgraph_decide_inlining_of_small_function): Handle new flags.
(cgraph_decide_inlining_incrementally): Likewise.
* opts.c (decode_options): Enable flag_inline_small_functions at -O2
* common.opt (finline-small-functions): New.
* Makefile.in (build/gengtype.o-warn): Work around PR29478
2007-09-04 Richard Guenther <rguenther@suse.de> 2007-09-04 Richard Guenther <rguenther@suse.de>
* tree-ssa-operands.c (add_virtual_operand): Only mark * tree-ssa-operands.c (add_virtual_operand): Only mark
......
...@@ -562,6 +562,10 @@ finline ...@@ -562,6 +562,10 @@ finline
Common Report Var(flag_no_inline,0) Init(2) Common Report Var(flag_no_inline,0) Init(2)
Pay attention to the \"inline\" keyword Pay attention to the \"inline\" keyword
finline-small-functions
Common Report Var(flag_inline_small_functions) Optimization
Integrate simple functions into their callers when code size is known to not growth
finline-functions finline-functions
Common Report Var(flag_inline_functions) Optimization Common Report Var(flag_inline_functions) Optimization
Integrate simple functions into their callers Integrate simple functions into their callers
......
...@@ -328,7 +328,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -328,7 +328,7 @@ Objective-C and Objective-C++ Dialects}.
-fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol
-fcrossjumping -fif-conversion -fif-conversion2 @gol -fcrossjumping -fif-conversion -fif-conversion2 @gol
-finline-functions -finline-functions-called-once @gol -finline-functions -finline-functions-called-once @gol
-finline-limit=@var{n} -fkeep-inline-functions @gol -finline-small-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
-fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
-fmodulo-sched -fmodulo-sched-allow-regmoves -fno-branch-count-reg @gol -fmodulo-sched -fmodulo-sched-allow-regmoves -fno-branch-count-reg @gol
-fno-default-inline -fno-defer-pop -fmove-loop-invariants @gol -fno-default-inline -fno-defer-pop -fmove-loop-invariants @gol
...@@ -5033,6 +5033,7 @@ compilation time. ...@@ -5033,6 +5033,7 @@ compilation time.
-ftree-fre @gol -ftree-fre @gol
-ftree-ch @gol -ftree-ch @gol
-funit-at-a-time @gol -funit-at-a-time @gol
-finline-small-functions @gol
-fmerge-constants} -fmerge-constants}
@option{-O} also turns on @option{-fomit-frame-pointer} on machines @option{-O} also turns on @option{-fomit-frame-pointer} on machines
...@@ -5172,6 +5173,15 @@ Don't pay attention to the @code{inline} keyword. Normally this option ...@@ -5172,6 +5173,15 @@ Don't pay attention to the @code{inline} keyword. Normally this option
is used to keep the compiler from expanding any functions inline. is used to keep the compiler from expanding any functions inline.
Note that if you are not optimizing, no functions can be expanded inline. Note that if you are not optimizing, no functions can be expanded inline.
@item -finline-small-functions
@opindex finline-small-functions
Integrate functions into their callers when their body is smaller than expected
function call code (so overall size of program gets smaller). The compiler
heuristically decides which functions are simple enough to be worth integrating
in this way.
Enabled at level @option{-O2}.
@item -finline-functions @item -finline-functions
@opindex finline-functions @opindex finline-functions
Integrate all simple functions into their callers. The compiler Integrate all simple functions into their callers. The compiler
......
...@@ -404,10 +404,10 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason) ...@@ -404,10 +404,10 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
if (n->inline_decl) if (n->inline_decl)
decl = n->inline_decl; decl = n->inline_decl;
if (!DECL_INLINE (decl)) if (!flag_inline_small_functions && !DECL_DECLARED_INLINE_P (decl))
{ {
if (reason) if (reason)
*reason = N_("function not inlinable"); *reason = N_("function not inline candidate");
return false; return false;
} }
...@@ -666,7 +666,8 @@ cgraph_decide_recursive_inlining (struct cgraph_node *node) ...@@ -666,7 +666,8 @@ cgraph_decide_recursive_inlining (struct cgraph_node *node)
int depth = 0; int depth = 0;
int n = 0; int n = 0;
if (optimize_size) if (optimize_size
|| (!flag_inline_functions && !DECL_DECLARED_INLINE_P (node->decl)))
return false; return false;
if (DECL_DECLARED_INLINE_P (node->decl)) if (DECL_DECLARED_INLINE_P (node->decl))
...@@ -863,6 +864,7 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -863,6 +864,7 @@ cgraph_decide_inlining_of_small_functions (void)
struct cgraph_node *where; struct cgraph_node *where;
int growth = int growth =
cgraph_estimate_size_after_inlining (1, edge->caller, edge->callee); cgraph_estimate_size_after_inlining (1, edge->caller, edge->callee);
const char *not_good = NULL;
growth -= edge->caller->global.insns; growth -= edge->caller->global.insns;
...@@ -916,13 +918,19 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -916,13 +918,19 @@ cgraph_decide_inlining_of_small_functions (void)
} }
} }
if ((!cgraph_maybe_hot_edge_p (edge) || optimize_size) && growth > 0) if (!cgraph_maybe_hot_edge_p (edge))
not_good = N_("call is unlikely and code size would grow");
if (!flag_inline_functions
&& !DECL_DECLARED_INLINE_P (edge->callee->decl))
not_good = N_("function not declared inline and code size would grow");
if (optimize_size)
not_good = N_("optimizing for size and code size would grow");
if (not_good && growth > 0)
{ {
if (!cgraph_recursive_inlining_p (edge->caller, edge->callee, if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
&edge->inline_failed)) &edge->inline_failed))
{ {
edge->inline_failed = edge->inline_failed = not_good;
N_("call is unlikely");
if (dump_file) if (dump_file)
fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed); fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
} }
...@@ -1363,7 +1371,9 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, ...@@ -1363,7 +1371,9 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node,
/* When the function body would grow and inlining the function won't /* When the function body would grow and inlining the function won't
eliminate the need for offline copy of the function, don't inline. eliminate the need for offline copy of the function, don't inline.
*/ */
if (mode == INLINE_SIZE if ((mode == INLINE_SIZE
|| (!flag_inline_functions
&& !DECL_DECLARED_INLINE_P (e->callee->decl)))
&& (cgraph_estimate_size_after_inlining (1, e->caller, e->callee) && (cgraph_estimate_size_after_inlining (1, e->caller, e->callee)
> e->caller->global.insns) > e->caller->global.insns)
&& cgraph_estimate_growth (e->callee) > 0) && cgraph_estimate_growth (e->callee) > 0)
......
...@@ -353,6 +353,7 @@ static bool profile_arc_flag_set, flag_profile_values_set; ...@@ -353,6 +353,7 @@ static bool profile_arc_flag_set, flag_profile_values_set;
static bool flag_unroll_loops_set, flag_tracer_set; static bool flag_unroll_loops_set, flag_tracer_set;
static bool flag_value_profile_transformations_set; static bool flag_value_profile_transformations_set;
static bool flag_peel_loops_set, flag_branch_probabilities_set; static bool flag_peel_loops_set, flag_branch_probabilities_set;
static bool flag_inline_functions_set;
/* Functions excluded from profiling. */ /* Functions excluded from profiling. */
...@@ -821,6 +822,7 @@ decode_options (unsigned int argc, const char **argv) ...@@ -821,6 +822,7 @@ decode_options (unsigned int argc, const char **argv)
if (optimize >= 2) if (optimize >= 2)
{ {
flag_inline_small_functions = 1;
flag_thread_jumps = 1; flag_thread_jumps = 1;
flag_crossjumping = 1; flag_crossjumping = 1;
flag_optimize_sibling_calls = 1; flag_optimize_sibling_calls = 1;
...@@ -1605,6 +1607,10 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1605,6 +1607,10 @@ common_handle_option (size_t scode, const char *arg, int value,
profile_arc_flag_set = true; profile_arc_flag_set = true;
break; break;
case OPT_finline_functions:
flag_inline_functions_set = true;
break;
case OPT_fprofile_use: case OPT_fprofile_use:
if (!flag_branch_probabilities_set) if (!flag_branch_probabilities_set)
flag_branch_probabilities = value; flag_branch_probabilities = value;
...@@ -1618,6 +1624,8 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1618,6 +1624,8 @@ common_handle_option (size_t scode, const char *arg, int value,
flag_tracer = value; flag_tracer = value;
if (!flag_value_profile_transformations_set) if (!flag_value_profile_transformations_set)
flag_value_profile_transformations = value; flag_value_profile_transformations = value;
if (!flag_inline_functions_set)
flag_inline_functions = value;
break; break;
case OPT_fprofile_generate: case OPT_fprofile_generate:
......
2007-09-04 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/loadpre8.c: Disable inlining.
* gcc.dg/tree-ssa/pr27236.c: Likewise.
* gcc.dg/tree-ssa/predcom-1.c: Likewise.
* gcc.dg/tree-ssa/predcom-2.c: Likewise.
* gcc.dg/tree-ssa/flatten-2.c: Avoid overactive tail call ellim.
* gcc.dg/tree-ssa/loadpre5.c: Likewise.
* gcc.dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c:
Likewise.
2007-09-04 Janus Weil <jaydub66@gmail.com> 2007-09-04 Janus Weil <jaydub66@gmail.com>
Tobias Burnus <burnus@net-b.de> Tobias Burnus <burnus@net-b.de>
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options -O2 } */ /* { dg-options -O2 } */
extern void do_something_usefull();
/* Check that we finish compiling even if instructed to /* Check that we finish compiling even if instructed to
flatten a cyclic callgraph. Verify we correctly flatten a cyclic callgraph. Verify we correctly
flatten with another function marked flatten in the flatten with another function marked flatten in the
...@@ -27,6 +28,7 @@ void __attribute__((flatten)) doubleindirect(void); ...@@ -27,6 +28,7 @@ void __attribute__((flatten)) doubleindirect(void);
static void doubleindirect2(void) static void doubleindirect2(void)
{ {
doubleindirect(); doubleindirect();
do_something_usefull ();
} }
static void doubleindirect1(void) static void doubleindirect1(void)
{ {
...@@ -42,6 +44,7 @@ static void subcycle1(void); ...@@ -42,6 +44,7 @@ static void subcycle1(void);
static void subcycle2(void) static void subcycle2(void)
{ {
subcycle1(); subcycle1();
do_something_usefull ();
} }
static void subcycle1(void) static void subcycle1(void)
{ {
...@@ -58,6 +61,7 @@ static void doublesubcycle2(void); ...@@ -58,6 +61,7 @@ static void doublesubcycle2(void);
static void doublesubcycle3(void) static void doublesubcycle3(void)
{ {
doublesubcycle1(); doublesubcycle1();
do_something_usefull ();
} }
static void doublesubcycle2(void) static void doublesubcycle2(void)
{ {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
/* { dg-options "-O2 -fdump-tree-pre-stats" } */ /* { dg-options "-O2 -fdump-tree-pre-stats" } */
int p; int p;
int r; int r;
__attribute__ ((noinline))
int a(void) int a(void)
{ {
return p; return p;
......
...@@ -24,7 +24,7 @@ typedef struct VEC_edge_base ...@@ -24,7 +24,7 @@ typedef struct VEC_edge_base
{ {
} }
VEC_edge_base; VEC_edge_base;
edge __attribute__ ((noinline)) edge
VEC_edge_base_index (const VEC_edge_base * vec_, unsigned ix_) VEC_edge_base_index (const VEC_edge_base * vec_, unsigned ix_)
{ {
} }
...@@ -56,7 +56,7 @@ ei_start_1 (VEC_edge_gc ** ev) ...@@ -56,7 +56,7 @@ ei_start_1 (VEC_edge_gc ** ev)
i.container = ev; i.container = ev;
return i; return i;
} }
ei_next (edge_iterator * i) __attribute__ ((noinline)) ei_next (edge_iterator * i)
{ {
} }
static __inline__ edge static __inline__ edge
...@@ -75,7 +75,7 @@ static __inline__ tree ...@@ -75,7 +75,7 @@ static __inline__ tree
get_def_from_ptr (def_operand_p def) get_def_from_ptr (def_operand_p def)
{ {
} }
tree __attribute__ ((noinline)) tree
phi_nodes (basic_block bb) phi_nodes (basic_block bb)
{ {
} }
......
...@@ -5,6 +5,7 @@ static inline int inline_read(volatile int *mem) ...@@ -5,6 +5,7 @@ static inline int inline_read(volatile int *mem)
{ {
return *mem; return *mem;
} }
__attribute__ ((noinline))
int foo_read(volatile int *mem) int foo_read(volatile int *mem)
{ {
return inline_read(mem); return inline_read(mem);
......
...@@ -6,6 +6,7 @@ void abort (void); ...@@ -6,6 +6,7 @@ void abort (void);
unsigned fib[1000]; unsigned fib[1000];
__attribute__ ((noinline))
void count_fib(void) void count_fib(void)
{ {
int i; int i;
...@@ -18,6 +19,7 @@ void count_fib(void) ...@@ -18,6 +19,7 @@ void count_fib(void)
unsigned avg[1000]; unsigned avg[1000];
__attribute__ ((noinline))
void count_averages(int n) void count_averages(int n)
{ {
int i; int i;
......
...@@ -6,6 +6,7 @@ void abort (void); ...@@ -6,6 +6,7 @@ void abort (void);
long int fib[1000]; long int fib[1000];
__attribute__ ((noinline))
void count_fib(void) void count_fib(void)
{ {
int i; int i;
...@@ -18,6 +19,7 @@ void count_fib(void) ...@@ -18,6 +19,7 @@ void count_fib(void)
int avg[1000]; int avg[1000];
__attribute__ ((noinline))
void count_averages(void) void count_averages(void)
{ {
int i; int i;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "../../tree-vect.h" #include "../../tree-vect.h"
__attribute__ ((noinline))
void interp_pitch(float *exc, float *interp, int pitch, int len) void interp_pitch(float *exc, float *interp, int pitch, int len)
{ {
int i,k; int i,k;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment