public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH GCC][1/4]Extend interface ref_at_iteration to compute ref @ (NITERS + ITERS)-th iteration
@ 2017-06-27 10:48 Bin Cheng
  2017-06-27 10:52 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2017-06-27 10:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd

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

Hi,
This is a simple patch extending interface ref_at_iteration in order to compute memory
refernce at (NITERS + ITERS)-th iteration.  This is for following predictive commoning
pass enhancement in which we need to compute reference after (NITERS) loop at
ITERS shifted iterations.
Bootstrap(O2/O3) in patch series on x86_64 and AArch64.  Is it OK?

Thanks,
bin
2017-06-21  Bin Cheng  <bin.cheng@arm.com>

	* tree-predcom.c (ref_at_iteration): Add parameter NITERS.  Compute
	memory reference to DR at (NITERS + ITERS)-th iteration of loop.

[-- Attachment #2: ref-at-iteration-20170620.txt --]
[-- Type: text/plain, Size: 2454 bytes --]

From ed1df7daca3d2dc2c3ba1c504d5431fba96d0887 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Tue, 20 Jun 2017 16:21:34 +0100
Subject: [PATCH 3/6] ref-at-iteration-20170620.txt

---
 gcc/tree-predcom.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index b7b1083..0238e87 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1370,11 +1370,12 @@ replace_ref_with (gimple *stmt, tree new_tree, bool set, bool in_lhs)
   gsi_insert_after (&bsi, new_stmt, GSI_NEW_STMT);
 }
 
-/* Returns a memory reference to DR in the ITER-th iteration of
-   the loop it was analyzed in.  Append init stmts to STMTS.  */
+/* Returns a memory reference to DR in the (NITERS + ITER)-th iteration
+   of the loop it was analyzed in.  Append init stmts to STMTS.  */
 
 static tree
-ref_at_iteration (data_reference_p dr, int iter, gimple_seq *stmts)
+ref_at_iteration (data_reference_p dr, int iter,
+		  gimple_seq *stmts, tree niters = NULL_TREE)
 {
   tree off = DR_OFFSET (dr);
   tree coff = DR_INIT (dr);
@@ -1383,14 +1384,27 @@ ref_at_iteration (data_reference_p dr, int iter, gimple_seq *stmts)
   tree ref_type = NULL_TREE;
   tree ref_op1 = NULL_TREE;
   tree ref_op2 = NULL_TREE;
-  if (iter == 0)
-    ;
-  else if (TREE_CODE (DR_STEP (dr)) == INTEGER_CST)
-    coff = size_binop (PLUS_EXPR, coff,
-		       size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter)));
-  else
-    off = size_binop (PLUS_EXPR, off,
-		      size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter)));
+  tree new_offset;
+
+  if (iter != 0)
+    {
+      new_offset = size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter));
+      if (TREE_CODE (new_offset) == INTEGER_CST)
+	coff = size_binop (PLUS_EXPR, coff, new_offset);
+      else
+	off = size_binop (PLUS_EXPR, off, new_offset);
+    }
+
+  if (niters != NULL_TREE)
+    {
+      niters = fold_convert (ssizetype, niters);
+      new_offset = size_binop (MULT_EXPR, DR_STEP (dr), niters);
+      if (TREE_CODE (niters) == INTEGER_CST)
+	coff = size_binop (PLUS_EXPR, coff, new_offset);
+      else
+	off = size_binop (PLUS_EXPR, off, new_offset);
+    }
+
   /* While data-ref analysis punts on bit offsets it still handles
      bitfield accesses at byte boundaries.  Cope with that.  Note that
      if the bitfield object also starts at a byte-boundary we can simply
-- 
1.9.1


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

* Re: [PATCH GCC][1/4]Extend interface ref_at_iteration to compute ref @ (NITERS + ITERS)-th iteration
  2017-06-27 10:48 [PATCH GCC][1/4]Extend interface ref_at_iteration to compute ref @ (NITERS + ITERS)-th iteration Bin Cheng
@ 2017-06-27 10:52 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-06-27 10:52 UTC (permalink / raw)
  To: Bin Cheng; +Cc: gcc-patches, nd

On Tue, Jun 27, 2017 at 12:48 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is a simple patch extending interface ref_at_iteration in order to compute memory
> refernce at (NITERS + ITERS)-th iteration.  This is for following predictive commoning
> pass enhancement in which we need to compute reference after (NITERS) loop at
> ITERS shifted iterations.
> Bootstrap(O2/O3) in patch series on x86_64 and AArch64.  Is it OK?

Ok.

> Thanks,
> bin
> 2017-06-21  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-predcom.c (ref_at_iteration): Add parameter NITERS.  Compute
>         memory reference to DR at (NITERS + ITERS)-th iteration of loop.

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

end of thread, other threads:[~2017-06-27 10:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 10:48 [PATCH GCC][1/4]Extend interface ref_at_iteration to compute ref @ (NITERS + ITERS)-th iteration Bin Cheng
2017-06-27 10:52 ` Richard Biener

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).