From 87d8dd6c4599c09fe4da43adac523cf81613217c Mon Sep 17 00:00:00 2001 From: Brad Lucier Date: Thu, 12 Nov 2015 22:27:47 +0000 Subject: [PATCH] [PATCH] Make disabled-optimization warning more informative; increase default max-gcse-memory * gcc/cprop.c (is_too_expensive): Remove. (gcse.h): Include. (one_cprop_pass): Call gcse_or_cprop_is_too_expensive, not is_too_expensive. * gcc/gcse.h (gcse_or_cprop_is_too_expensive): Declare. * gcc/gcse.c (is_too_expensive): Rename to ... (gcse_or_cprop_is_too_expensive): ... this. Expand warning to add required size of max-gcse-memory. (one_pre_gcse_pass): Use it. (one_code_hoisting_pass): Use it. * gcc/params.def (max-gcse-memory): Increase from 50MB to 128MB. From-SVN: r230276 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/cprop.c | 44 ++------------------------------------------ gcc/gcse.c | 22 ++++++++++++---------- gcc/gcse.h | 1 + gcc/params.def | 2 +- 5 files changed, 30 insertions(+), 53 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5093ce06aba..1d8da275bcc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-11-12 Brad Lucier + + * gcc/cprop.c (is_too_expensive): Remove. + (gcse.h): Include. + (one_cprop_pass): Call gcse_or_cprop_is_too_expensive, not + is_too_expensive. + * gcc/gcse.h (gcse_or_cprop_is_too_expensive): Declare. + * gcc/gcse.c (is_too_expensive): Rename to ... + (gcse_or_cprop_is_too_expensive): ... this. + Expand warning to add required size of max-gcse-memory. + (one_pre_gcse_pass): Use it. + (one_code_hoisting_pass): Use it. + * gcc/params.def (max-gcse-memory): Increase from 50MB to 128MB. + 2015-11-12 James Norris Joseph Myers diff --git a/gcc/cprop.c b/gcc/cprop.c index 082f9fd2c88..7f1acc09eb0 100644 --- a/gcc/cprop.c +++ b/gcc/cprop.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "dbgcnt.h" #include "cfgloop.h" +#include "gcse.h" /* An obstack for our working variables. */ @@ -1724,47 +1725,6 @@ bypass_conditional_jumps (void) return changed; } -/* Return true if the graph is too expensive to optimize. PASS is the - optimization about to be performed. */ - -static bool -is_too_expensive (const char *pass) -{ - /* Trying to perform global optimizations on flow graphs which have - a high connectivity will take a long time and is unlikely to be - particularly useful. - - In normal circumstances a cfg should have about twice as many - edges as blocks. But we do not want to punish small functions - which have a couple switch statements. Rather than simply - threshold the number of blocks, uses something with a more - graceful degradation. */ - if (n_edges_for_fn (cfun) > 20000 + n_basic_blocks_for_fn (cfun) * 4) - { - warning (OPT_Wdisabled_optimization, - "%s: %d basic blocks and %d edges/basic block", - pass, n_basic_blocks_for_fn (cfun), - n_edges_for_fn (cfun) / n_basic_blocks_for_fn (cfun)); - - return true; - } - - /* If allocating memory for the cprop bitmap would take up too much - storage it's better just to disable the optimization. */ - if ((n_basic_blocks_for_fn (cfun) - * SBITMAP_SET_SIZE (max_reg_num ()) - * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY) - { - warning (OPT_Wdisabled_optimization, - "%s: %d basic blocks and %d registers", - pass, n_basic_blocks_for_fn (cfun), max_reg_num ()); - - return true; - } - - return false; -} - /* Main function for the CPROP pass. */ static int @@ -1775,7 +1735,7 @@ one_cprop_pass (void) /* Return if there's nothing to do, or it is too expensive. */ if (n_basic_blocks_for_fn (cfun) <= NUM_FIXED_BLOCKS + 1 - || is_too_expensive (_ ("const/copy propagation disabled"))) + || gcse_or_cprop_is_too_expensive (_ ("const/copy propagation disabled"))) return 0; global_const_prop_count = local_const_prop_count = 0; diff --git a/gcc/gcse.c b/gcc/gcse.c index dcee396562c..64f04c7e045 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -510,7 +510,6 @@ static void trim_ld_motion_mems (void); static void update_ld_motion_stores (struct gcse_expr *); static void clear_modify_mem_tables (void); static void free_modify_mem_tables (void); -static bool is_too_expensive (const char *); #define GNEW(T) ((T *) gmalloc (sizeof (T))) #define GCNEW(T) ((T *) gcalloc (1, sizeof (T))) @@ -2565,7 +2564,7 @@ one_pre_gcse_pass (void) /* Return if there's nothing to do, or it is too expensive. */ if (n_basic_blocks_for_fn (cfun) <= NUM_FIXED_BLOCKS + 1 - || is_too_expensive (_("PRE disabled"))) + || gcse_or_cprop_is_too_expensive (_("PRE disabled"))) return 0; /* We need alias. */ @@ -3493,7 +3492,7 @@ one_code_hoisting_pass (void) /* Return if there's nothing to do, or it is too expensive. */ if (n_basic_blocks_for_fn (cfun) <= NUM_FIXED_BLOCKS + 1 - || is_too_expensive (_("GCSE disabled"))) + || gcse_or_cprop_is_too_expensive (_("GCSE disabled"))) return 0; doing_code_hoisting_p = true; @@ -3957,9 +3956,13 @@ update_ld_motion_stores (struct gcse_expr * expr) /* Return true if the graph is too expensive to optimize. PASS is the optimization about to be performed. */ -static bool -is_too_expensive (const char *pass) +bool +gcse_or_cprop_is_too_expensive (const char *pass) { + unsigned int memory_request = (n_basic_blocks_for_fn (cfun) + * SBITMAP_SET_SIZE (max_reg_num ()) + * sizeof (SBITMAP_ELT_TYPE)); + /* Trying to perform global optimizations on flow graphs which have a high connectivity will take a long time and is unlikely to be particularly useful. @@ -3981,13 +3984,12 @@ is_too_expensive (const char *pass) /* If allocating memory for the dataflow bitmaps would take up too much storage it's better just to disable the optimization. */ - if ((n_basic_blocks_for_fn (cfun) - * SBITMAP_SET_SIZE (max_reg_num ()) - * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY) + if (memory_request > MAX_GCSE_MEMORY) { warning (OPT_Wdisabled_optimization, - "%s: %d basic blocks and %d registers", - pass, n_basic_blocks_for_fn (cfun), max_reg_num ()); + "%s: %d basic blocks and %d registers; increase --param max-gcse-memory above %d", + pass, n_basic_blocks_for_fn (cfun), max_reg_num (), + memory_request); return true; } diff --git a/gcc/gcse.h b/gcc/gcse.h index e28a07d4aa4..752815327cc 100644 --- a/gcc/gcse.h +++ b/gcc/gcse.h @@ -40,5 +40,6 @@ extern struct target_gcse *this_target_gcse; #endif void gcse_c_finalize (void); +extern bool gcse_or_cprop_is_too_expensive (const char *); #endif diff --git a/gcc/params.def b/gcc/params.def index c5d96e7e38b..41fd8a84da5 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -218,7 +218,7 @@ DEFPARAM(PARAM_STACK_FRAME_GROWTH, DEFPARAM(PARAM_MAX_GCSE_MEMORY, "max-gcse-memory", "The maximum amount of memory to be allocated by GCSE.", - 50 * 1024 * 1024, 0, 0) + 128 * 1024 * 1024, 0, 0) /* The GCSE optimization of an expression will avoided if the ratio of insertions to deletions is greater than this value. */ -- 2.30.2