[patch] small cselib.c speedup - at least in theory

Steven Bosscher stevenb.gcc@gmail.com
Thu Jun 22 23:38:00 GMT 2006


Hi,

There is a shortcut in alias.c that makes (mem:BLK (scratch)) alias
everything.  In cselib.c, callmem is a fake MEM that aliases everything
to speed up invalidating memory for non-pure calls, but this callmem is
defined as (mem:BLKmode (const_int 0)), i.e. 0 instead of a SCRATCH.
This means that we sometimes do too much work in canon_true_dependence
when we could just take that shortcut.

Bootstrapped c,c++,fortran on x86_64-suse-linux-gnu, but I haven't had
the time to test this (regression testing or seeing if this actually
does help measurably).  I'm really just posting this for comments, and
if someone wants to pick this up and test it a bit, that'd be nice ;-)

Gr.
Steven


	* cselib.c (cselib_init): Set up callmem as (mem:BLK (scratch))
	to take the shortcut...
	* alias.c (canon_true_dependence): ...here.  Update comment.

Index: cselib.c
===================================================================
--- cselib.c	(revision 114907)
+++ cselib.c	(working copy)
@@ -1455,9 +1455,11 @@ cselib_init (bool record_memory)
 				       sizeof (cselib_val), 10);
   value_pool = create_alloc_pool ("value", RTX_CODE_SIZE (VALUE), 100);
   cselib_record_memory = record_memory;
-  /* This is only created once.  */
+
+  /* (mem:BLK (scratch)) is a special mechanism to conflict with everything,
+     see canon_true_dependence.  This is only created once.  */
   if (! callmem)
-    callmem = gen_rtx_MEM (BLKmode, const0_rtx);
+    callmem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
 
   cselib_nregs = max_reg_num ();
 
Index: alias.c
===================================================================
--- alias.c	(revision 114907)
+++ alias.c	(working copy)
@@ -2225,7 +2225,8 @@ canon_true_dependence (rtx mem, enum mac
     return 1;
 
   /* (mem:BLK (scratch)) is a special mechanism to conflict with everything.
-     This is used in epilogue deallocation functions.  */
+     This is used in epilogue deallocation functions and in cselib (and
+     probably in a few other places).  */
   if (GET_MODE (x) == BLKmode && GET_CODE (XEXP (x, 0)) == SCRATCH)
     return 1;
   if (GET_MODE (mem) == BLKmode && GET_CODE (XEXP (mem, 0)) == SCRATCH)



More information about the Gcc-patches mailing list