This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ia64 performance regression
- To: Richard Henderson <rth at redhat dot com>
- Subject: Re: ia64 performance regression
- From: Steve Christiansen <smc at us dot ibm dot com>
- Date: Thu, 25 Oct 2001 10:49:52 -0700
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <20011009135337.B1523@us.ibm.com> <20011016172801.B5704@redhat.com>
On Tue, Oct 16, 2001 at 05:28:01PM -0700, Richard Henderson wrote:
> On Tue, Oct 09, 2001 at 01:53:37PM -0700, Steve Christiansen wrote:
> > What is the purpose of the following code in loop.c (loop_regs_scan)?
> >
> > for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
> > {
> > regs->array[i].may_not_optimize = 1;
> > regs->array[i].set_in_loop = 1;
> > }
>
> I don't know. Paranoia, probably.
>
> I'm pretty sure this ought to be
>
> /* Invalidate all hard registers clobbered by calls. With one exception:
> a call-clobbered PIC register is still function-invariant for our
> purposes, since we can hoist any PIC calculations out of the loop.
> Thus the call to rtx_varies_p. */
> if (loop->has_call)
> for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
> if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i)
> && rtx_varies_p (gen_rtx_REG (Pmode, i), /*for_alias=*/1))
> {
> ...
> }
I made a patch from the code above (thanks Richard), with one minor
correction:
- if (loop->has_call)
+ if (LOOP_INFO (loop)->has_call)
To summarize for gcc-patches, this is a fix for the problem described in
http://gcc.gnu.org/ml/gcc/2001-10/msg00619.html
loop_regs_scan() was invalidating all hardware registers in loops
which prevented hoisting of global data references, causing performance
problems on ia64.
The fix is to be more selective by invalidating call-clobbered registers,
but recognizing that a call-clobbered PIC register can be considered
function-invariant since PIC calculations can be hoisted out of the loop.
I don't have a regression test for this problem because the generated
code is correct either way. It's just a bit slower without the patch.
Bootstrapped and tested on i686-pc-linux-gnu and ia64-unknown-linux.
Please apply if ok, as I don't have write access.
Thanks
Steve
2001-10-24 Steve Christiansen <smc@us.ibm.com>
* loop.c (loop_regs_scan): Don't invalidate PIC register.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.362
diff -u -p -d -r1.362 loop.c
--- loop.c 2001/10/11 03:15:54 1.362
+++ loop.c 2001/10/19 22:38:12
@@ -8821,11 +8821,18 @@ loop_regs_scan (loop, extra_size)
memset (last_set, 0, regs->num * sizeof (rtx));
}
- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- {
- regs->array[i].may_not_optimize = 1;
- regs->array[i].set_in_loop = 1;
- }
+ /* Invalidate all hard registers clobbered by calls. With one exception:
+ a call-clobbered PIC register is still function-invariant for our
+ purposes, since we can hoist any PIC calculations out of the loop.
+ Thus the call to rtx_varies_p. */
+ if (LOOP_INFO (loop)->has_call)
+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i)
+ && rtx_varies_p (gen_rtx_REG (Pmode, i), /*for_alias=*/1))
+ {
+ regs->array[i].may_not_optimize = 1;
+ regs->array[i].set_in_loop = 1;
+ }
#ifdef AVOID_CCMODE_COPIES
/* Don't try to move insns which set CC registers if we should not