+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
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)
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
/* 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.
#include "df.h"
#include "hashtab.h"
#include "except.h"
+#include "params.h"
/* The data stored for the loop. */
/* 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)
/* 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.
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;
= 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;
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;
/* 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>.
"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
/* 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.
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 */