On 10/25/2013 11:19 AM, Martin Jambor wrote:
> Hi,
>
> On Thu, Oct 24, 2013 at 01:02:51AM +0200, Steven Bosscher wrote:
>> On Wed, Oct 23, 2013 at 6:46 PM, Martin Jambor wrote:
>>
>>> /* Perform the second half of the transformation started in
>>> @@ -4522,7 +4704,15 @@ ira (FILE *f)
>>> allocation because of -O0 usage or because the function is too
>>> big. */
>>> if (ira_conflicts_p)
>>> - find_moveable_pseudos ();
>>> + {
>>> + df_analyze ();
>>> + calculate_dominance_info (CDI_DOMINATORS);
>>> +
>>> + find_moveable_pseudos ();
>>> + split_live_ranges_for_shrink_wrap ();
>>> +
>>> + free_dominance_info (CDI_DOMINATORS);
>>> + }
>>>
>> You probably want to add another df_analyze if
>> split_live_ranges_for_shrink_wrap makes code transformations. AFAIU
>> find_moveable_pseudos doesn't change global liveness but your
>> transformation might. IRA/LRA need up-to-date DF_LR results to compute
>> allocno live ranges.
>>
> OK, I have changed the patch to fo that (it is below, still bootstraps
> and passes tests on x86_64 fine). However, I have noticed that the
> corresponding part in function ira now looks like:
>
> /* ... */
> if (delete_trivially_dead_insns (get_insns (), max_reg_num ()))
> df_analyze ();
>
> /* It is not worth to do such improvement when we use a simple
> allocation because of -O0 usage or because the function is too
> big. */
> if (ira_conflicts_p)
> {
> df_analyze ();
> calculate_dominance_info (CDI_DOMINATORS);
>
> find_moveable_pseudos ();
> if (split_live_ranges_for_shrink_wrap ())
> df_analyze ();
>
> free_dominance_info (CDI_DOMINATORS);
> }
> /* ... */
>
> So, that left me wondering whether the first call to df_analyze is
> actually necessary, or whether perhaps the data are actually already
> up to date. What do you think?
I guess it needs some investigation. delete_trivially_dead_insns code
was taken from the old RA. First of all, I don't know how many insns
are really trivially dead before RA in optimization and non-optimization
mode. May be the code can be removed at all. I'll put it on my todo list.
The patch is ok to commit. Thanks for working on this, Martin.
>
> 2013-10-23 Martin Jambor <mjam...@suse.cz>
>
> PR rtl-optimization/10474
> * ira.c (find_moveable_pseudos): Do not calculate dominance info
> nor df analysis.
> (interesting_dest_for_shprep): New function.
> (split_live_ranges_for_shrink_wrap): Likewise.
> (ira): Calculate dominance info and df analysis. Call
> split_live_ranges_for_shrink_wrap.
>
> testsuite/
> * gcc.dg/pr10474.c: New testcase.
> * gcc.dg/ira-shrinkwrap-prep-1.c: Likewise.
> * gcc.dg/ira-shrinkwrap-prep-2.c: Likewise.
>
>