This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Speedup CSE by 5%



On Mon, 17 Jan 2005, Jeffrey A Law wrote:

> Our of curiosity, do your profiles indicate if there's any call
> sites for approx_reg_cost which are particularly abusive? 

I didn't see anything abusive. However, the patch below saves 10%
completely unnecessary calls for lpgparse.i: There is no need to copy_rtx
before calling fold_rtx, as fold_rtx always makes a copy if it changes
anything. In the frequent case that it did nothing, we can thus avoid
doing any cost computation for the "new" trx folded.

(Speed gain for lpgparse.i was a little more than 0.5%.)

>I also
> wonder if we're doing a lot of redundant calls because of the 
> redundant processing of insns inherent in our current CSE
> implementation.

I guess so, too, but I don't think that is solved more easily than
trying to reduce the redundance in cse.c overall.

This patch was tested by building stage 1 with vanilla CVS, then applying
the patch and completing bootstrap for all default languages. If I
understand the bootstrap machinery right, this means it didn't cause any
change in the compiled output for all of GCC. (On i686-pc-linux-gnu.)


Arend


2005-01-25  Arend Bayer  <arend.bayer@web.de>
	
	* cse.c (find_best_addr): Don't call copy_rtx before calling
	fold_rtx. Save cost recomputation if fold_rtx did nothing.


Index: gcc/cse.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cse.c,v
retrieving revision 1.331
diff -u -p -r1.331 cse.c
--- gcc/cse.c	23 Jan 2005 19:13:50 -0000	1.331
+++ gcc/cse.c	24 Jan 2005 22:32:25 -0000
@@ -2844,18 +2844,21 @@ find_best_addr (rtx insn, rtx *loc, enum
      be valid and produce better code.  */
   if (!REG_P (addr))
     {
-      rtx folded = fold_rtx (copy_rtx (addr), NULL_RTX);
-      int addr_folded_cost = address_cost (folded, mode);
-      int addr_cost = address_cost (addr, mode);
-
-      if ((addr_folded_cost < addr_cost
-	   || (addr_folded_cost == addr_cost
-	       /* ??? The rtx_cost comparison is left over from an older
-		  version of this code.  It is probably no longer helpful.  */
-	       && (rtx_cost (folded, MEM) > rtx_cost (addr, MEM)
-		   || approx_reg_cost (folded) < approx_reg_cost (addr))))
-	  && validate_change (insn, loc, folded, 0))
-	addr = folded;
+      rtx folded = fold_rtx (addr, NULL_RTX);
+      if (folded != addr)
+	{
+	  int addr_folded_cost = address_cost (folded, mode);
+	  int addr_cost = address_cost (addr, mode);
+
+	  if ((addr_folded_cost < addr_cost
+	       || (addr_folded_cost == addr_cost
+		   /* ??? The rtx_cost comparison is left over from an older
+		      version of this code.  It is probably no longer helpful.*/
+		   && (rtx_cost (folded, MEM) > rtx_cost (addr, MEM)
+		       || approx_reg_cost (folded) < approx_reg_cost (addr))))
+	      && validate_change (insn, loc, folded, 0))
+	    addr = folded;
+	}
     }
 
   /* If this address is not in the hash table, we can't look for equivalences



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]