diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-02-20 12:56:01 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-02-20 12:56:01 +0000 |
commit | 86482d6bf55db0eea64cf549bf04c6763f4074a4 (patch) | |
tree | c37b4e8fdb620aa7e10238c591d1e5c0c5753af2 /gcc | |
parent | cd102cfc1332aec577e6ed9cbed3283297ed7ba1 (diff) | |
download | gcc-86482d6bf55db0eea64cf549bf04c6763f4074a4.tar.gz |
PR middle-end/39157
* Makefile.in (loop-invariant.o): Depend on $(PARAMS_H).
* params.h (LOOP_INVARIANT_MAX_BBS_IN_LOOP): Define.
* params.def (loop-invariant-max-bbs-in-loop): New parameter.
* opts.c (decode_options): Set loop-invariant-max-bbs-in-loop
parameter to 1000 for -O1 by default.
* doc/invoke.texi (loop-invariant-max-bbs-in-loop): Document new
parameter.
* loop-invariant.c: Include params.h.
(move_loop_invariants): Don't call move_single_loop_invariants on
very large loops.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144320 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 7 | ||||
-rw-r--r-- | gcc/loop-invariant.c | 9 | ||||
-rw-r--r-- | gcc/opts.c | 9 | ||||
-rw-r--r-- | gcc/params.def | 9 | ||||
-rw-r--r-- | gcc/params.h | 5 |
7 files changed, 49 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64bfbe06296..bb0ad681a4a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2009-02-20 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/39157 + * Makefile.in (loop-invariant.o): Depend on $(PARAMS_H). + * params.h (LOOP_INVARIANT_MAX_BBS_IN_LOOP): Define. + * params.def (loop-invariant-max-bbs-in-loop): New parameter. + * opts.c (decode_options): Set loop-invariant-max-bbs-in-loop + parameter to 1000 for -O1 by default. + * doc/invoke.texi (loop-invariant-max-bbs-in-loop): Document new + parameter. + * loop-invariant.c: Include params.h. + (move_loop_invariants): Don't call move_single_loop_invariants on + very large loops. + 2009-02-20 Jaka Mocnik <jaka@xlab.si> * calls.c (emit_library_call_value_1): Use slot_offset instead of diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 3e09ccadbf8..5e3fc9d5a56 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2814,7 +2814,7 @@ loop-iv.o : loop-iv.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(BASIC_BLOCK_H) \ loop-invariant.o : loop-invariant.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \ $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(EXPR_H) $(RECOG_H) coretypes.h \ $(TM_H) $(TM_P_H) $(FUNCTION_H) $(FLAGS_H) $(DF_H) $(OBSTACK_H) output.h \ - $(HASHTAB_H) except.h + $(HASHTAB_H) except.h $(PARAMS_H) cfgloopmanip.o : cfgloopmanip.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \ $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(CFGLAYOUT_H) output.h \ coretypes.h $(TM_H) cfghooks.h $(OBSTACK_H) $(TREE_FLOW_H) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f52b6433160..f12124ccdc1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7766,6 +7766,13 @@ lower quality register allocation algorithm will be used. The algorithm do not use pseudo-register conflicts. The default value of the parameter is 2000. +@item loop-invariant-max-bbs-in-loop +Loop invariant motion can be very expensive, both in compile time and +in amount of needed compile time memory, with very large loops. Loops +with more basic blocks than this parameter won't have loop invariant +motion optimization performed on them. The default value of the +parameter is 1000 for -O1 and 10000 for -O2 and above. + @end table @end table diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 8b8345fe5fd..82e18297e20 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -1,5 +1,6 @@ /* RTL-level loop invariant motion. - Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 + Free Software Foundation, Inc. This file is part of GCC. @@ -52,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "df.h" #include "hashtab.h" #include "except.h" +#include "params.h" /* The data stored for the loop. */ @@ -1345,7 +1347,10 @@ move_loop_invariants (void) /* Process the loops, innermost first. */ FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST) { - move_single_loop_invariants (loop); + /* move_single_loop_invariants for very large loops + is time consuming and might need a lot of memory. */ + if (loop->num_nodes <= (unsigned) LOOP_INVARIANT_MAX_BBS_IN_LOOP) + move_single_loop_invariants (loop); } FOR_EACH_LOOP (li, loop, 0) diff --git a/gcc/opts.c b/gcc/opts.c index cccb80b403f..8ae79ae0889 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1,5 +1,5 @@ /* Command line option handling. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Contributed by Neil Booth. @@ -811,6 +811,7 @@ decode_options (unsigned int argc, const char **argv) static int initial_avg_aliased_vops; static int initial_min_crossjump_insns; static int initial_max_fields_for_field_sensitive; + static int initial_loop_invariant_max_bbs_in_loop; static unsigned int initial_lang_mask; unsigned int i, lang_mask; @@ -833,6 +834,8 @@ decode_options (unsigned int argc, const char **argv) = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value; initial_max_fields_for_field_sensitive = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value; + initial_loop_invariant_max_bbs_in_loop + = compiler_params[PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP].value; } else lang_mask = initial_lang_mask; @@ -943,6 +946,10 @@ decode_options (unsigned int argc, const char **argv) set_param_value ("max-fields-for-field-sensitive", (opt2) ? 100 : initial_max_fields_for_field_sensitive); + /* For -O1 only do loop invariant motion for very small loops. */ + set_param_value ("loop-invariant-max-bbs-in-loop", + (opt2) ? initial_loop_invariant_max_bbs_in_loop : 1000); + /* -O3 optimizations. */ opt3 = (optimize >= 3); flag_predictive_commoning = opt3; diff --git a/gcc/params.def b/gcc/params.def index ea5efc3e85c..3f7b2e77ed6 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -1,5 +1,5 @@ /* params.def - Run-time parameters. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Written by Mark Mitchell <mark@codesourcery.com>. @@ -764,6 +764,13 @@ DEFPARAM (PARAM_SWITCH_CONVERSION_BRANCH_RATIO, "a switch conversion to take place", 8, 1, 0) +/* Avoid doing loop invariant motion on very large loops. */ + +DEFPARAM (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP, + "loop-invariant-max-bbs-in-loop", + "max basic blocks number in loop for loop invariant motion", + 10000, 0, 0) + /* Local variables: mode:c diff --git a/gcc/params.h b/gcc/params.h index 501259c78e1..fb2dad5706f 100644 --- a/gcc/params.h +++ b/gcc/params.h @@ -1,5 +1,6 @@ /* params.h - Run-time parameters. - Copyright (C) 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009 + Free Software Foundation, Inc. Written by Mark Mitchell <mark@codesourcery.com>. This file is part of GCC. @@ -173,4 +174,6 @@ typedef enum compiler_param PARAM_VALUE (PARAM_IRA_MAX_CONFLICT_TABLE_SIZE) #define SWITCH_CONVERSION_BRANCH_RATIO \ PARAM_VALUE (PARAM_SWITCH_CONVERSION_BRANCH_RATIO) +#define LOOP_INVARIANT_MAX_BBS_IN_LOOP \ + PARAM_VALUE (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) #endif /* ! GCC_PARAMS_H */ |