diff mbox

[PR,debug/59992,#1/2] avoid quadratic behavior for the removal of useless values

Message ID orzjl39580.fsf@livre.home
State New
Headers show

Commit Message

Alexandre Oliva March 6, 2014, 7:05 a.m. UTC
On Feb 27, 2014, Alexandre Oliva <aoliva@redhat.com> wrote:

> I wasn't entirely sure this wouldn't invalidate assumptions made in
> callers of cselib_preserve_only_values (the function called at the end
> of each extended basic block), but some analysis, plus comparing before
> and after assembly output ;-), made sure it didn't ;-)

For some values of didn't ;-) PR60381 proved otherwise.  On PA, FP args
may be passed by reference with incoming-rtl (mem (plus (reg)
(const_int))), and we don't preserve the VALUE for the REG in this case.
There may be other such cases, so I decided to not try to fix just this
one.

Fortunately, the second patch of this series, that moves permanent
entries to an alternate table, brings about by itself nearly all of the
benefit of the two together.

I'm checking this in.
diff mbox

Patch

Revert r208220.

From: Alexandre Oliva <aoliva@redhat.com>

for gcc/ChangeLog

	PR debug/60381
	Revert:
	2014-02-28  Alexandre Oliva <aoliva@redhat.com>
	PR debug/59992
	* cselib.c (remove_useless_values): Skip to avoid quadratic
	behavior if the condition moved from...
	(cselib_process_insn): ... here holds.
---
 gcc/cselib.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/gcc/cselib.c b/gcc/cselib.c
index 0fcfe28..4dfc557 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -681,14 +681,6 @@  remove_useless_values (void)
 {
   cselib_val **p, *v;
 
-  if (n_useless_values <= MAX_USELESS_VALUES
-      /* remove_useless_values is linear in the hash table size.  Avoid
-         quadratic behavior for very large hashtables with very few
-	 useless elements.  */
-      || ((unsigned int)n_useless_values
-	  <= (cselib_hash_table.elements () - n_debug_values) / 4))
-    return;
-
   /* First pass: eliminate locations that reference the value.  That in
      turn can make more values useless.  */
   do
@@ -2720,7 +2712,13 @@  cselib_process_insn (rtx insn)
 
   cselib_current_insn = NULL_RTX;
 
-  remove_useless_values ();
+  if (n_useless_values > MAX_USELESS_VALUES
+      /* remove_useless_values is linear in the hash table size.  Avoid
+         quadratic behavior for very large hashtables with very few
+	 useless elements.  */
+      && ((unsigned int)n_useless_values
+	  > (cselib_hash_table.elements () - n_debug_values) / 4))
+    remove_useless_values ();
 }
 
 /* Initialize cselib for one pass.  The caller must also call