This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: regclass speedup
- From: Mike Stump <mstump at apple dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 23 Jan 2003 10:06:05 -0800
- Subject: Re: regclass speedup
On Wednesday, January 15, 2003, at 12:46 AM, Richard Henderson wrote:
On Fri, Jan 10, 2003 at 01:17:38PM -0800, Mike Stump wrote:
Here is a little one that avoids re-initializing for regclass. Speeds
up regclass by about 88% for one of my compiles (Finder_FE). The only
issue may be, can any of the things that influence auto-inc or
auto-dec
availability change from function to function?
Couple o' things. First, there is a comment,
/* Initialize information about which register classes can be used
for
pseudos that are auto-incremented or auto-decremented. It would
seem better to put this in init_reg_sets, but we need to be able
to allocate rtx, which we can't do that early. */
Comment updated.
which appears to be false now -- init_reg_sets is called
after init_ggc. So it appears as if we can just move the
code rather than creating the late_regclass_init.
Done. I kept as much of the original temporal ordering as possible and
put it last in the per compilation unit init code. I also kept it easy
to move around, just in case people want to defer the code, or move it
later, and to keep functions reasonably sized.
Second,
rtx r = gen_rtx_REG (VOIDmode, 0);
REGNO (r) = j;
PUT_MODE (r, m);
this is a no-no. We cannot randomly modify register rtxs
we get back from gen_rtx_REG. It may be shared. We should
be using gen_rtx_raw_REG instead.
Latent bug... I also fixed this.
Retesting now, ok otherwise? Ok for 3.3 branch as well?
2003-01-23 Mike Stump <mrs@apple.com>
* regclass.c (init_reg_autoinc): New function.
(regclass): Move initialization of forbidden_inc_dec_class from
here...
(init_regs): to here. Avoids reinitialization for each
function, saving time.
Doing diffs in regclass.c.~1~:
*** regclass.c.~1~ Thu Jan 23 09:53:18 2003
--- regclass.c Thu Jan 23 09:53:39 2003
*************** init_regs ()
*** 578,583 ****
--- 578,585 ----
init_reg_sets_1 ();
init_reg_modes ();
+
+ init_reg_autoinc ();
}
/* Initialize some fake stack-frame MEM references for use in
*************** scan_one_insn (insn, pass)
*** 1143,1179 ****
return insn;
}
! /* This is a pass of the compiler that scans all instructions
! and calculates the preferred class for each pseudo-register.
! This information can be accessed later by calling
`reg_preferred_class'.
! This pass comes just before local register allocation. */
void
! regclass (f, nregs, dump)
! rtx f;
! int nregs;
! FILE *dump;
{
- rtx insn;
- int i;
- int pass;
-
- init_recog ();
-
- costs = (struct costs *) xmalloc (nregs * sizeof (struct costs));
-
#ifdef FORBIDDEN_INC_DEC_CLASSES
!
! in_inc_dec = (char *) xmalloc (nregs);
!
! /* Initialize information about which register classes can be used
for
! pseudos that are auto-incremented or auto-decremented. It would
! seem better to put this in init_reg_sets, but we need to be able
! to allocate rtx, which we can't do that early. */
for (i = 0; i < N_REG_CLASSES; i++)
{
! rtx r = gen_rtx_REG (VOIDmode, 0);
enum machine_mode m;
int j;
--- 1145,1162 ----
return insn;
}
! /* Initialize information about which register classes can be used for
! pseudos that are auto-incremented or auto-decremented. */
void
! init_reg_autoinc ()
{
#ifdef FORBIDDEN_INC_DEC_CLASSES
! int i;
for (i = 0; i < N_REG_CLASSES; i++)
{
! rtx r = gen_rtx_raw_REG (VOIDmode, 0);
enum machine_mode m;
int j;
*************** regclass (f, nregs, dump)
*** 1213,1218 ****
--- 1196,1227 ----
}
}
}
+ #endif /* FORBIDDEN_INC_DEC_CLASSES */
+ }
+
+ /* This is a pass of the compiler that scans all instructions
+ and calculates the preferred class for each pseudo-register.
+ This information can be accessed later by calling
`reg_preferred_class'.
+ This pass comes just before local register allocation. */
+
+ void
+ regclass (f, nregs, dump)
+ rtx f;
+ int nregs;
+ FILE *dump;
+ {
+ rtx insn;
+ int i;
+ int pass;
+
+ init_recog ();
+
+ costs = (struct costs *) xmalloc (nregs * sizeof (struct costs));
+
+ #ifdef FORBIDDEN_INC_DEC_CLASSES
+
+ in_inc_dec = (char *) xmalloc (nregs);
+
#endif /* FORBIDDEN_INC_DEC_CLASSES */
/* Normally we scan the insns once and determine the best class to
use for
--------------
Attachment:
regclass.diffs
Description: Binary data