[patch] gcse.c (expr_equiv_p): Very tiny speedup.

Kazu Hirata kazu@cs.umass.edu
Fri Jun 27 14:32:00 GMT 2003


Hi,

Attached is a patch to speed up expr_equiv_p().

CONST_INT's are always shared, so

  INTVAL (x) == INTVAL (y) iff x == y

Since the function returns 1 very early if x == y, after that we
know that INTVAL (x) != INTVAL (y).

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2003-06-27  Kazu Hirata  <kazu@cs.umass.edu>

	* gcse.c (expr_equiv_p): Replace expressions that are known to
	be 0 with 0.

Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.251
diff -u -4 -r1.251 gcse.c
--- gcse.c	19 Jun 2003 22:26:53 -0000	1.251
+++ gcse.c	27 Jun 2003 06:32:39 -0000
@@ -1817,9 +1817,9 @@
   if (x == y)
     return 1;
 
   if (x == 0 || y == 0)
-    return x == y;
+    return 0;
 
   code = GET_CODE (x);
   if (code != GET_CODE (y))
     return 0;
@@ -1831,12 +1831,10 @@
   switch (code)
     {
     case PC:
     case CC0:
-      return x == y;
-
     case CONST_INT:
-      return INTVAL (x) == INTVAL (y);
+      return 0;
 
     case LABEL_REF:
       return XEXP (x, 0) == XEXP (y, 0);
 



More information about the Gcc-patches mailing list