re PR middle-end/39157 (Code that compiles fine in 1GB of memory with 4.1.2 requires > 20GB in 4.2.* and higher)

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.

From-SVN: r144320
This commit is contained in:
Jakub Jelinek 2009-02-20 13:56:01 +01:00 committed by Jakub Jelinek
parent da9c199f2c
commit b1fb9f5699
7 changed files with 49 additions and 6 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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

View file

@ -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 */