The patch is modified based on the review comments from Richard, Bernd and 
David. 

The following changes are done to incorporate the comments received on the 
previous mail.

1. With this patch the liveness of the Loop is not stored on the LOOPDATA 
structures. The liveness is calculated based on the current loops
 for which the invariant is checked and the regs_used is calculated. 
2. Memory leaks are fixed.
3. Reworked on the comments section based on Bernd's comments.

Bootstrapped and regtested for i386 and Microblaze target.

SPEC CPU 2000 benchmarks are run on i386 target and following is the summary of 
the results.

SPEC CPU 2000 INT benchmarks.

( Gemoean Score without the change vs Geomean score with reg pressure change = 
3745.193 vs 3745.328)

SPEC CPU 2000 FP benchmarks.

( Gemoean Score without the change vs Geomean score with reg pressure change = 
4741.825 vs 4748.364).


    [Patch,rtl Optimization]: Better register pressure estimate for loop 
invariant code motion

    Calculate the loop liveness used for regs for calculating the register 
pressure
    in the cost estimation.  Loop liveness is based on the following properties.
    We only need to find the set of objects that are live at the birth or the 
header
    of the loop. We don't need to calculate the live through the loop by 
considering
    live in and live out of all the basic blocks of the loop. This is based on 
the
    point that the set of objects that are live-in at the birth or header of 
the loop
    will be live-in at every node in the loop.

    If a v live is out at the header of the loop then the variable is live-in 
at every node
    in the loop. To prove this, consider a loop L with header h such that the 
variable v
    defined at d is live-in at h. Since v is live at h, d is not part of L. 
This follows i
    from the dominance property, i.e. h is strictly dominated by d. 
Furthermore, there
    exists a path from h to a use of v which does not go through d. For every 
node p in
    the loop, since the loop is strongly connected and node is a component of 
the CFG,
    there exists a path, consisting only of nodes of L from p to h. 
Concatenating these
    two paths proves that v is live-in and live-out of p.

    Calculate the live-out and live-in for the exit edge of the loop. This 
patch considers
    liveness for not only the loop latch but also the liveness outside the 
loops.

    ChangeLog:
    2015-12-15  Ajit Agarwal  <ajit...@xilinx.com>

        * loop-invariant.c
        (find_invariants_to_move): Add the logic of regs_used based
        on liveness.
        * cfgloopanal.c
        (estimate_reg_pressure_cost): Update the heuristics in presence
        of call_p.

    Signed-off-by:Ajit Agarwal ajit...@xilinx.com.

Thanks & Regards
Ajit

-----Original Message-----
From: Bernd Schmidt [mailto:bschm...@redhat.com] 
Sent: Wednesday, December 09, 2015 7:34 PM
To: Ajit Kumar Agarwal; Richard Biener
Cc: Jeff Law; GCC Patches; Vinod Kathail; Shail Aditya Gupta; Vidhumouli 
Hunsigida; Nagaraju Mekala
Subject: Re: [Patch,rtl Optimization]: Better register pressure estimate for 
Loop Invariant Code Motion.

On 12/09/2015 12:22 PM, Ajit Kumar Agarwal wrote:
>
> This is because the available_regs = 6 and the regs_needed = 1 and 
> new_regs = 0 and the regs_used = 10.  As the reg_used that are based 
> on the Liveness given above is greater than the available_regs, then
 > it's candidate of spill and the estimate_register_pressure calculates  > the 
 > spill cost. This spill cost is greater than inv_cost and gain  > comes to be 
 > negative. The disables the loop invariant for the above  > testcase.

As far as I can tell this loop does not lead to a spill. Hence, failure of this 
testcase would suggest there is something wrong with your idea.

>> +  FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)  {

Formatting.

>> +    /* Loop Liveness is based on the following proprties.

"properties"

>> +       we only require to calculate the set of objects that are live at
>> +       the birth or the header of the loop.
>> +       We don't need to calculate the live through the Loop considering
>> +       Live in and Live out of all the basic blocks of the Loop. This is
>> +       because the set of objects. That are live-in at the birth or header
>> +       of the loop will be live-in at every node in the Loop.
>> +       If a v live out at the header of the loop then the variable is 
>> live-in
>> +       at every node in the Loop. To prove this, Consider a Loop L with 
>> header
>> +       h such that The variable v defined at d is live-in at h. Since v is 
>> live
>> +       at h, d is not part of L. This follows from the dominance property, 
>> i.e.
>> +       h is strictly dominated by d. Furthermore, there exists a path from 
>> h to
>> +       a use of v which does not go through d. For every node of the loop, 
>> p,
>> +       since the loop is strongly connected Component of the CFG, there 
>> exists
>> +       a path, consisting only of nodes of L from p to h. Concatenating 
>> those
>> +       two paths prove that v is live-in and live-out Of p.  */

Please Refrain From Randomly Capitalizing Words, and please also fix the 
grammar ("set of objects. That are live-in"). These problems make this comment 
(and also your emails) extremely hard to read.

Partly for that reason, I can't quite make up my mind whether this patch makes 
things better or just different. The testcase failure makes me think it's 
probably not an improvement.

>> +    bitmap_ior_into (&LOOP_DATA (loop)->regs_live, DF_LR_IN (loop->header));
>> +    bitmap_ior_into (&LOOP_DATA (loop)->regs_live, DF_LR_OUT 
>> + (loop->header));

Formatting.


Bernd

Attachment: pressure-licm.patch
Description: pressure-licm.patch

Reply via email to