Re: Question on GCC register optimization.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Henri Cloetens <henri.cloetens@xxxxxxxxxx> writes:
> Hello All,
>
> I am still working on a GCC backend for a custom processor.
>
> When running the compiler with following flags:
>
> gcc -O3 -S -c -fcprop-registers -frename-registers,
>
> I find out it does not optimize the allocation of the registers.
> The routine used is simple function, and what I see is that
> it allocates excess registers, in short, it does not optimize
> register usage. I would expect it:
>   - performs register lifetime analysis
>   - performs register renames as to minimize cost.

-frename-registers actually renames for the opposite effect: make as
much use of the register file as possible.  This in turn gives the
second scheduling pass more freedom.

So if you want to use the smallest register set, it'd be better
to drop -frename-registers.

> Question is: I think I invoked the 2 optimizers. Could
>    anybody point me to documentation on them ?. I think
>    I am missing some target 'hooks', but I have no idea what it is.

Both -frename-registers and -fcprop-registers run after register
allocation proper -- they don't modify the RA itself.  The choice
of which registers to save and restore is fixed by the RA,
and -frename-registers and -fcprop-registers have to work
within those constraints.  In other words, if the RA decides
to save and restore a register X, later passes usually won't
undo that decision.  If the RA decides not to save and restore X,
later passes usually won't add a save and restore.

So the passes to look at are IRA and LRA.  If you use -da,
the *.ira and *.reload dumps give the information for IRA
and LRA respectively.

The options themselves are documented in doc/invoke.texi,
but if you're interested in how the passes actually work,
it's better to look at the comments at the start of the
respective .c files.

Thanks,
Richard




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux