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]

[patch] reload1.c: A very tiny speedup.


Hi,

Attached is a patch to make a very tiny speedup in
reload_cse_simplify_set().

First, cselib_lookup() can be called earlier, and if no equivalent
things are found, just return before computing old_cost.

Second, no rtx is both a constant and a reg at the same time, so we
can simplify the conditionals.

This patch saves about 3.6% of calls to rtx_cost() on one particular
example.

Tested on h8300 port.  OK to apply?

Kazu Hirata

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

	* reload1.c (reload_cse_simplify_set): Call cselib_lookup earlier.
	Don't check if SRC is a constant.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.399
diff -c -r1.399 reload1.c
*** reload1.c	16 Jun 2003 21:41:06 -0000	1.399
--- reload1.c	18 Jun 2003 15:28:14 -0000
***************
*** 8224,8244 ****
      return 0;
  #endif
  
    /* If memory loads are cheaper than register copies, don't change them.  */
    if (GET_CODE (src) == MEM)
      old_cost = MEMORY_MOVE_COST (GET_MODE (src), dclass, 1);
-   else if (CONSTANT_P (src))
-     old_cost = rtx_cost (src, SET);
    else if (GET_CODE (src) == REG)
      old_cost = REGISTER_MOVE_COST (GET_MODE (src),
  				   REGNO_REG_CLASS (REGNO (src)), dclass);
    else
-     /* ???   */
      old_cost = rtx_cost (src, SET);
  
-   val = cselib_lookup (src, GET_MODE (SET_DEST (set)), 0);
-   if (! val)
-     return 0;
    for (l = val->locs; l; l = l->next)
      {
        rtx this_rtx = l->loc;
--- 8224,8242 ----
      return 0;
  #endif
  
+   val = cselib_lookup (src, GET_MODE (SET_DEST (set)), 0);
+   if (! val)
+     return 0;
+ 
    /* If memory loads are cheaper than register copies, don't change them.  */
    if (GET_CODE (src) == MEM)
      old_cost = MEMORY_MOVE_COST (GET_MODE (src), dclass, 1);
    else if (GET_CODE (src) == REG)
      old_cost = REGISTER_MOVE_COST (GET_MODE (src),
  				   REGNO_REG_CLASS (REGNO (src)), dclass);
    else
      old_cost = rtx_cost (src, SET);
  
    for (l = val->locs; l; l = l->next)
      {
        rtx this_rtx = l->loc;


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