This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on register renaming in rtl loop unroll pass
- From: "Bin.Cheng" <amker dot cheng at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 28 Jun 2013 18:28:02 +0800
- Subject: Re: Question on register renaming in rtl loop unroll pass
- References: <CAHFci2-8WTRo4rGER6QHEoh_8tL0AXmpZqs4Sovy6OgeG2mm5g at mail dot gmail dot com> <1413819 dot OeunHWRmPy at polaris>
On Fri, Jun 28, 2013 at 6:10 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Hi, I have a question about register renaming in rtl loop unroll.
>> For an example loop:
>> .L1:
>> [r162] <- x
>> r162 <- r162 + 4
>> ...
>> b .L1
>>
>> After unrolling:
>> .L1:
>> [r162] <- x
>> r197 <- r162 + 4
>> r162 <- r197
>> ...
>> [r162] <- y
>> r162 <- r197 + 4
>> ...
>> b .L1
>> Why not:
>> .L1:
>> [r162] <- x
>> r162 <- r162 + 4
>> ...
>> [r162] <- y
>> r162 <- r162 + 4
>> ...
>> b .L1
>>
>> Thus less copy instructions and can take advantage of auto-increment.
>> Any ideas?
>
> The general principle is to avoid pseudo-registers with long live ranges
> because this unnecessarily contraints the RTL optimizers.
>
Understood. Thanks.
The problem is auto-inc-dec is weak and can only capture
post-increment in first part of code, generating even worse code for
RA:
.L1:
r197 <- r162
[r197++] <- x
...
[r162+4] <- y
r162 <- r197+0x4
...
b .L1
Now we have two live registers and it seems hard to eliminate.
So could the unrolled codes be like below?
>> .L1:
>> [r162] <- x
>> r162 <- r162 + 4
>> r197 <- r162
>> ...
>> [r197] <- y
>> r197 <- r197 + 4
>> r162 <- r197
>> ...
>> b .L1
Thanks.
bin