public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
@ 2015-03-04 10:27 Ajit Kumar Agarwal
  2015-03-23 16:36 ` Ajit Kumar Agarwal
  2015-04-23 19:10 ` Richard Sandiford
  0 siblings, 2 replies; 6+ messages in thread
From: Ajit Kumar Agarwal @ 2015-03-04 10:27 UTC (permalink / raw)
  To: vmakarov, GCC Patches
  Cc: Vinod Kathail, Shail Aditya Gupta, Vidhumouli Hunsigida, Nagaraju Mekala

[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]

Hello All:

The changes are made in the patch to update the heuristics for loop invariant for address arithemetic at RTL Level. 
The heuristics are updated with the consideration of single def and use for register pressure calculation instead 
Of ignoring it and also to update the estimated register pressure cost along with the check of actual uses with
Address uses.

With the above change, gains are seen in the Geomean for Mibench/EEMBC benchmarks for microblaze target. No
Regression is seen in deja GNU regressions tests for microblaze.

Please let us know your feedback.

commit 039b95028c93f99fc1da7fa255f9b5fff4e17223
Author: Ajit Kumar Agarwal <ajitkum@xhdspdgnu.(none)>
Date:   Wed Mar 4 15:46:45 2015 +0530

    [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
    
    The changes are made in the patch to update the heuristics
    for loop invariant for address arithmetic. The heuristics is
    changed to incorporate the single def and use in the register
    pressure calculation in order to move the invariant out of
    loop. The heuristics are further changed to not to use the
    check for addr uses with actual uses. Also changes are done in
    the heuristics of estimated register pressure cost.
    
    ChangeLog:
    2015-03-04  Ajit Agarwal  <ajitkum@xilinx.com>
    
            * loop-invariant.c (gain_for_invariant): update the
            heuristics for estimate_reg_pressure_cost.
            (get_inv_cost): Remove the check for addr uses with
            actual uses. Add the single def and use in the register
            pressure for invariants.
    
    Signed-off-by:Ajit Agarwal ajitkum@xilinx.com

Thanks & Regards
Ajit

[-- Attachment #2: 0001-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch --]
[-- Type: application/octet-stream, Size: 2986 bytes --]

From 039b95028c93f99fc1da7fa255f9b5fff4e17223 Mon Sep 17 00:00:00 2001
From: Ajit Kumar Agarwal <ajitkum@xhdspdgnu.(none)>
Date: Wed, 4 Mar 2015 15:46:45 +0530
Subject: [PATCH] [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.

The changes are made in the patch to update the heuristics
for loop invariant for address arithmetic. The heuristics is
changed to incorporate the single def and use in the register
pressure calculation in order to move the invariant out of
loop. The heuristics are further changed to not to use the
check for addr uses with actual uses. Also changes are done in
the heuristics of estimated register pressure cost.

ChangeLog:
2015-03-04  Ajit Agarwal  <ajitkum@xilinx.com>

        * loop-invariant.c (gain_for_invariant): update the
        heuristics for estimate_reg_pressure_cost.
        (get_inv_cost): Remove the check for addr uses with
        actual uses. Add the single def and use in the register
        pressure for invariants.

Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
---
 gcc/loop-invariant.c |   30 +++---------------------------
 1 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 59aab57..84598e1 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -1156,8 +1156,7 @@ get_inv_cost (struct invariant *inv, int *comp_cost, unsigned *regs_needed,
       ret = 0;
     }
 
-  if (!inv->cheap_address
-      || inv->def->n_addr_uses < inv->def->n_uses)
+  if (!inv->cheap_address)
     (*comp_cost) += inv->cost * inv->eqno;
 
 #ifdef STACK_REGS
@@ -1220,27 +1219,6 @@ get_inv_cost (struct invariant *inv, int *comp_cost, unsigned *regs_needed,
 	      ret = 1;
 	    }
 	}
-      if (check_p
-	  /* We need to check always_executed, since if the original value of
-	     the invariant may be preserved, we may need to keep it in a
-	     separate register.  TODO check whether the register has an
-	     use outside of the loop.  */
-	  && dep->always_executed
-	  && !dep->def->uses->next)
-	{
-	  /* If this is a single use, after moving the dependency we will not
-	     need a new register.  */
-	  if (! flag_ira_loop_pressure)
-	    aregs_needed[0]--;
-	  else
-	    {
-	      int nregs;
-	      enum reg_class pressure_class;
-
-	      pressure_class = get_pressure_class_and_nregs (inv->insn, &nregs);
-	      aregs_needed[pressure_class] -= nregs;
-	    }
-	}
 
       if (! flag_ira_loop_pressure)
 	regs_needed[0] += aregs_needed[0];
@@ -1276,10 +1254,8 @@ gain_for_invariant (struct invariant *inv, unsigned *regs_needed,
 
   if (! flag_ira_loop_pressure)
     {
-      size_cost = (estimate_reg_pressure_cost (new_regs[0] + regs_needed[0],
-					       regs_used, speed, call_p)
-		   - estimate_reg_pressure_cost (new_regs[0],
-						 regs_used, speed, call_p));
+      size_cost =  estimate_reg_pressure_cost (regs_needed[0],
+					       regs_used, speed, call_p);
     }
   else if (ret < 0)
     return -1;
-- 
1.7.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
  2015-03-04 10:27 [Patch] OPT: Update heuristics for loop-invariant for address arithmetic Ajit Kumar Agarwal
@ 2015-03-23 16:36 ` Ajit Kumar Agarwal
  2015-03-23 21:58   ` Vladimir Makarov
  2015-04-23 21:59   ` Jeff Law
  2015-04-23 19:10 ` Richard Sandiford
  1 sibling, 2 replies; 6+ messages in thread
From: Ajit Kumar Agarwal @ 2015-03-23 16:36 UTC (permalink / raw)
  To: vmakarov, GCC Patches
  Cc: Vinod Kathail, Shail Aditya Gupta, Vidhumouli Hunsigida, Nagaraju Mekala

Hello All:

Did you get a chance to look at the below patch.

Thanks & Regards
Ajit

-----Original Message-----
From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org] On Behalf Of Ajit Kumar Agarwal
Sent: Wednesday, March 04, 2015 3:57 PM
To: vmakarov@redhat.com; GCC Patches
Cc: Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.

Hello All:

The changes are made in the patch to update the heuristics for loop invariant for address arithemetic at RTL Level. 
The heuristics are updated with the consideration of single def and use for register pressure calculation instead Of ignoring it and also to update the estimated register pressure cost along with the check of actual uses with Address uses.

With the above change, gains are seen in the Geomean for Mibench/EEMBC benchmarks for microblaze target. No Regression is seen in deja GNU regressions tests for microblaze.

Please let us know your feedback.

commit 039b95028c93f99fc1da7fa255f9b5fff4e17223
Author: Ajit Kumar Agarwal <ajitkum@xhdspdgnu.(none)>
Date:   Wed Mar 4 15:46:45 2015 +0530

    [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
    
    The changes are made in the patch to update the heuristics
    for loop invariant for address arithmetic. The heuristics is
    changed to incorporate the single def and use in the register
    pressure calculation in order to move the invariant out of
    loop. The heuristics are further changed to not to use the
    check for addr uses with actual uses. Also changes are done in
    the heuristics of estimated register pressure cost.
    
    ChangeLog:
    2015-03-04  Ajit Agarwal  <ajitkum@xilinx.com>
    
            * loop-invariant.c (gain_for_invariant): update the
            heuristics for estimate_reg_pressure_cost.
            (get_inv_cost): Remove the check for addr uses with
            actual uses. Add the single def and use in the register
            pressure for invariants.
    
    Signed-off-by:Ajit Agarwal ajitkum@xilinx.com

Thanks & Regards
Ajit

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
  2015-03-23 16:36 ` Ajit Kumar Agarwal
@ 2015-03-23 21:58   ` Vladimir Makarov
  2015-04-23 21:59   ` Jeff Law
  1 sibling, 0 replies; 6+ messages in thread
From: Vladimir Makarov @ 2015-03-23 21:58 UTC (permalink / raw)
  To: Ajit Kumar Agarwal, GCC Patches
  Cc: Vinod Kathail, Shail Aditya Gupta, Vidhumouli Hunsigida, Nagaraju Mekala



On 2015-03-23 12:35 PM, Ajit Kumar Agarwal wrote:
> Hello All:
>
> Did you get a chance to look at the below patch.
>
> Thanks & Regards
> Ajit
>
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org] On Behalf Of Ajit Kumar Agarwal
> Sent: Wednesday, March 04, 2015 3:57 PM
> To: vmakarov@redhat.com; GCC Patches
> Cc: Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
> Subject: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
>
> Hello All:
>
> The changes are made in the patch to update the heuristics for loop invariant for address arithemetic at RTL Level. 
> The heuristics are updated with the consideration of single def and use for register pressure calculation instead Of ignoring it and also to update the estimated register pressure cost along with the check of actual uses with Address uses.
>
> With the above change, gains are seen in the Geomean for Mibench/EEMBC benchmarks for microblaze target. No Regression is seen in deja GNU regressions tests for microblaze.
>
>
  Sorry, I am not a maintainer/reviewer of loop invariant motion pass. 
I had no power to approve this, especially when you change mostly code
for ! flag_ira_loop_pressure.

  I only should say that microblaze is not a primary target.  You should
demonstrate improvement on a primary target, x86/x86-64 the best. 
SPEC2000 or SPEC2006 would be a good benchmark for this.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
  2015-03-04 10:27 [Patch] OPT: Update heuristics for loop-invariant for address arithmetic Ajit Kumar Agarwal
  2015-03-23 16:36 ` Ajit Kumar Agarwal
@ 2015-04-23 19:10 ` Richard Sandiford
  2015-04-24  8:38   ` Ajit Kumar Agarwal
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Sandiford @ 2015-04-23 19:10 UTC (permalink / raw)
  To: Ajit Kumar Agarwal
  Cc: vmakarov, GCC Patches, Vinod Kathail, Shail Aditya Gupta,
	Vidhumouli Hunsigida, Nagaraju Mekala

Very delayed answer, sorry...

Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com> writes:
> Hello All:
>
> The changes are made in the patch to update the heuristics for loop
> invariant for address arithemetic at RTL Level.  The heuristics are
> updated with the consideration of single def and use for register
> pressure calculation instead Of ignoring it and also to update the
> estimated register pressure cost along with the check of actual uses
> with Address uses.
>
> With the above change, gains are seen in the Geomean for Mibench/EEMBC
> benchmarks for microblaze target. No Regression is seen in deja GNU
> regressions tests for microblaze.

Since thispatch is basically removing code, were you able to analyse why
that code was having a detrimental effect?  I assume it benefited some
target originally.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
  2015-03-23 16:36 ` Ajit Kumar Agarwal
  2015-03-23 21:58   ` Vladimir Makarov
@ 2015-04-23 21:59   ` Jeff Law
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Law @ 2015-04-23 21:59 UTC (permalink / raw)
  To: Ajit Kumar Agarwal, vmakarov, GCC Patches
  Cc: Vinod Kathail, Shail Aditya Gupta, Vidhumouli Hunsigida, Nagaraju Mekala

On 03/23/2015 10:35 AM, Ajit Kumar Agarwal wrote:
> Hello All:
>
> Did you get a chance to look at the below patch.
>
> Thanks & Regards
> Ajit
>
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org] On Behalf Of Ajit Kumar Agarwal
> Sent: Wednesday, March 04, 2015 3:57 PM
> To: vmakarov@redhat.com; GCC Patches
> Cc: Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
> Subject: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
>
> Hello All:
>
> The changes are made in the patch to update the heuristics for loop invariant for address arithemetic at RTL Level.
> The heuristics are updated with the consideration of single def and use for register pressure calculation instead Of ignoring it and also to update the estimated register pressure cost along with the check of actual uses with Address uses.
>
> With the above change, gains are seen in the Geomean for Mibench/EEMBC benchmarks for microblaze target. No Regression is seen in deja GNU regressions tests for microblaze.
>
> Please let us know your feedback.
>
> commit 039b95028c93f99fc1da7fa255f9b5fff4e17223
> Author: Ajit Kumar Agarwal <ajitkum@xhdspdgnu.(none)>
> Date:   Wed Mar 4 15:46:45 2015 +0530
>
>      [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
>
>      The changes are made in the patch to update the heuristics
>      for loop invariant for address arithmetic. The heuristics is
>      changed to incorporate the single def and use in the register
>      pressure calculation in order to move the invariant out of
>      loop. The heuristics are further changed to not to use the
>      check for addr uses with actual uses. Also changes are done in
>      the heuristics of estimated register pressure cost.
>
>      ChangeLog:
>      2015-03-04  Ajit Agarwal  <ajitkum@xilinx.com>
>
>              * loop-invariant.c (gain_for_invariant): update the
>              heuristics for estimate_reg_pressure_cost.
>              (get_inv_cost): Remove the check for addr uses with
>              actual uses. Add the single def and use in the register
>              pressure for invariants.
This work should probably be coordinated with the Intel folks who are 
looking to change if/when LICM for address expressions.

See the thread:

[PATCH, PR target/65103, 2/3] Propagate address constants into loops for 
i386

jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.
  2015-04-23 19:10 ` Richard Sandiford
@ 2015-04-24  8:38   ` Ajit Kumar Agarwal
  0 siblings, 0 replies; 6+ messages in thread
From: Ajit Kumar Agarwal @ 2015-04-24  8:38 UTC (permalink / raw)
  To: Richard Sandiford
  Cc: vmakarov, GCC Patches, Vinod Kathail, Shail Aditya Gupta,
	Vidhumouli Hunsigida, Nagaraju Mekala



-----Original Message-----
From: Richard Sandiford [mailto:rdsandiford@googlemail.com] 
Sent: Friday, April 24, 2015 12:40 AM
To: Ajit Kumar Agarwal
Cc: vmakarov@redhat.com; GCC Patches; Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: [Patch] OPT: Update heuristics for loop-invariant for address arithmetic.

Very delayed answer, sorry...

Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com> writes:
> Hello All:
>
> The changes are made in the patch to update the heuristics for loop 
> invariant for address arithemetic at RTL Level.  The heuristics are 
> updated with the consideration of single def and use for register 
> pressure calculation instead Of ignoring it and also to update the 
> estimated register pressure cost along with the check of actual uses 
> with Address uses.
>
> With the above change, gains are seen in the Geomean for Mibench/EEMBC 
> benchmarks for microblaze target. No Regression is seen in deja GNU 
> regressions tests for microblaze.

>>Since thispatch is basically removing code, were you able to analyse why that code was having a detrimental effect?  I assume it benefited some target ??>>originally.

This patch modified the estimated register pressure cost for non ira based register pressure(flag_ira_loop_pressure is not set).
Following changes were made in the estimated register pressure cost.

size_cost = (estimate_reg_pressure_cost (new_regs[0] + regs_needed[0],
                                               regs_used, speed, call_p)
                   - estimate_reg_pressure_cost (new_regs[0],
                                                 regs_used, speed, call_p));

is changed to 

size_cost =  estimate_reg_pressure_cost (regs_needed[0],
					       regs_used, speed, call_p);

This looks reasonable change for the estimated_reg_pressure_cost calculation. The other changes I have made, For the single use for the given
Def the current code does not include such invariants in the register pressure calculation which I have enabled including the single use for the
Given def for the register pressure calculation. Though the comment in the code says that there won't be a new register for single use after moving,
But moving such invariants outside the loop will affect the register pressures as  the spans of the live range after moving out of loops differs from 
The original loop. Since the Live range spans varies such cases should surely affect the registers pressure.

The above explanation looks reasonable and the code that does not include such invariants into register pressure is removed in the patch.

I don't any see background or the patches in the past that explicit made the above check as part of  any performance improvement or bug fix.

Thanks & Regards
Ajit

 



Thanks,
Richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-24  8:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 10:27 [Patch] OPT: Update heuristics for loop-invariant for address arithmetic Ajit Kumar Agarwal
2015-03-23 16:36 ` Ajit Kumar Agarwal
2015-03-23 21:58   ` Vladimir Makarov
2015-04-23 21:59   ` Jeff Law
2015-04-23 19:10 ` Richard Sandiford
2015-04-24  8:38   ` Ajit Kumar Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).