+2011-01-13 Jeff Law <law@redhat.com>
+
+ * PR rtl-optimization/39077
+ * doc/invoke.texi (max-gcse-insertion-ratio): Document.
+ * params.h (MAX_GCSE_INSERTION_RATIO): Define.
+ * params.def (PARAM_MAX_GCSE_INSERTION_RATIO): Define.
+ * lcm.c (pre_edge_lcm): Properly initialize output sbitmaps.
+ * gcse.c (prune_insertions_deletions): New function.
+ (compute_pre_data): Use it.
+
2011-01-13 Dodji Seketeli <dodji@redhat.com>
PR debug/PR46973
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-@c 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+@c 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
@c Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
optimization. If more memory than specified is required, the
optimization will not be done.
+@item max-gcse-insertion-ratio
+If the ratio of expression insertions to deletions is larger than this value
+for any expression, then RTL PRE will insert or remove the expression and thus
+leave partially redundant computations in the instruction stream. The default value is 20.
+
@item max-pending-list-length
The maximum number of pending dependencies scheduling will allow
before flushing the current state and starting over. Large functions
/* Global common subexpression elimination/Partial redundancy elimination
and global constant/copy propagation for GNU compiler.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC.
sbitmap_free (prune_exprs);
}
+/* It may be necessary to insert a large number of insns on edges to
+ make the existing occurrences of expressions fully redundant. This
+ routine examines the set of insertions and deletions and if the ratio
+ of insertions to deletions is too high for a particular expression, then
+ the expression is removed from the insertion/deletion sets.
+
+ N_ELEMS is the number of elements in the hash table. */
+
+static void
+prune_insertions_deletions (int n_elems)
+{
+ sbitmap_iterator sbi;
+ sbitmap prune_exprs;
+
+ /* We always use I to iterate over blocks/edges and J to iterate over
+ expressions. */
+ unsigned int i, j;
+
+ /* Counts for the number of times an expression needs to be inserted and
+ number of times an expression can be removed as a result. */
+ int *insertions = GCNEWVEC (int, n_elems);
+ int *deletions = GCNEWVEC (int, n_elems);
+
+ /* Set of expressions which require too many insertions relative to
+ the number of deletions achieved. We will prune these out of the
+ insertion/deletion sets. */
+ prune_exprs = sbitmap_alloc (n_elems);
+ sbitmap_zero (prune_exprs);
+
+ /* Iterate over the edges counting the number of times each expression
+ needs to be inserted. */
+ for (i = 0; i < (unsigned) n_edges; i++)
+ {
+ EXECUTE_IF_SET_IN_SBITMAP (pre_insert_map[i], 0, j, sbi)
+ insertions[j]++;
+ }
+
+ /* Similarly for deletions, but those occur in blocks rather than on
+ edges. */
+ for (i = 0; i < (unsigned) last_basic_block; i++)
+ {
+ EXECUTE_IF_SET_IN_SBITMAP (pre_delete_map[i], 0, j, sbi)
+ deletions[j]++;
+ }
+
+ /* Now that we have accurate counts, iterate over the elements in the
+ hash table and see if any need too many insertions relative to the
+ number of evaluations that can be removed. If so, mark them in
+ PRUNE_EXPRS. */
+ for (j = 0; j < (unsigned) n_elems; j++)
+ if (deletions[j]
+ && ((unsigned) insertions[j] / deletions[j]) > MAX_GCSE_INSERTION_RATIO)
+ SET_BIT (prune_exprs, j);
+
+ /* Now prune PRE_INSERT_MAP and PRE_DELETE_MAP based on PRUNE_EXPRS. */
+ EXECUTE_IF_SET_IN_SBITMAP (prune_exprs, 0, j, sbi)
+ {
+ for (i = 0; i < (unsigned) n_edges; i++)
+ RESET_BIT (pre_insert_map[i], j);
+
+ for (i = 0; i < (unsigned) last_basic_block; i++)
+ RESET_BIT (pre_delete_map[i], j);
+ }
+
+ sbitmap_free (prune_exprs);
+ free (insertions);
+ free (deletions);
+}
+
/* Top level routine to do the dataflow analysis needed by PRE. */
static void
antloc = NULL;
sbitmap_vector_free (ae_kill);
ae_kill = NULL;
+
+ prune_insertions_deletions (expr_hash_table.n_elems);
}
\f
/* PRE utilities */
};
#include "gt-gcse.h"
+
/* Generic partial redundancy elimination with lazy code motion support.
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
- 2010 Free Software Foundation, Inc.
+ 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC.
*insert = sbitmap_vector_alloc (num_edges, n_exprs);
*del = sbitmap_vector_alloc (last_basic_block, n_exprs);
+ sbitmap_vector_zero (*insert, num_edges);
+ sbitmap_vector_zero (*del, last_basic_block);
compute_insert_delete (edge_list, antloc, later, laterin, *insert, *del);
sbitmap_vector_free (laterin);
/* params.def - Run-time parameters.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011
Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
"The maximum amount of memory to be allocated by GCSE",
50 * 1024 * 1024, 0, 0)
+/* The GCSE optimization of an expression will avoided if the ratio of
+ insertions to deletions is greater than this value. */
+DEFPARAM(PARAM_MAX_GCSE_INSERTION_RATIO,
+ "max-gcse-insertion-ratio",
+ "The maximum ratio of insertions to deletions of expressions in GCSE",
+ 20, 0, 0)
+
/* This is the threshold ratio when to perform partial redundancy
elimination after reload. We perform partial redundancy elimination
when the following holds:
/* params.h - Run-time parameters.
- Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
PARAM_VALUE (PARAM_MAX_PENDING_LIST_LENGTH)
#define MAX_GCSE_MEMORY \
((size_t) PARAM_VALUE (PARAM_MAX_GCSE_MEMORY))
+#define MAX_GCSE_INSERTION_RATIO \
+ ((size_t) PARAM_VALUE (PARAM_MAX_GCSE_INSERTION_RATIO))
#define GCSE_AFTER_RELOAD_PARTIAL_FRACTION \
PARAM_VALUE (PARAM_GCSE_AFTER_RELOAD_PARTIAL_FRACTION)
#define GCSE_AFTER_RELOAD_CRITICAL_FRACTION \