This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH GCC][5/6]Record initialization statements and only insert it for valid chains


On Fri, May 12, 2017 at 12:28 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This patch caches initialization statements and only inserts it for valid chains.
> Looks like current code even inserts such stmts for invalid chains which will be
> deleted as dead code afterwards.
>
> Bootstrap and test on x86_64 and AArch64, is it OK?

Ping this one because it's a prerequisite patch for following predcom
enhancement.
Also I updated the patch a little bit.

Bootstrap and test along with following patches of predcom on x86_64
and AArch64.  Is it OK?

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

    * tree-predcom.c (struct chain): New field init_seq.
    (release_chain): Release init_seq.
    (prepare_initializers_chain): Record intialization stmts in above
    field.  Discard it if chain is invalid.
    (insert_init_seqs): New function.
    (tree_predictive_commoning_loop): Call insert_init_seqs.
From df8db56c584864ab6c8e6c2b7dcab2d57daf830a Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Mon, 26 Jun 2017 10:33:18 +0100
Subject: [PATCH 2/6] chain-init-seq-20170620.txt

---
 gcc/tree-predcom.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 4547b6d..260caaf 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -294,6 +294,9 @@ typedef struct chain
   /* Initializers for the variables.  */
   vec<tree> inits;
 
+  /* gimple stmts intializing the initial variables of the chain.  */
+  gimple_seq init_seq;
+
   /* True if there is a use of a variable with the maximal distance
      that comes after the root in the loop.  */
   unsigned has_max_use_after : 1;
@@ -511,6 +514,8 @@ release_chain (chain_p chain)
   chain->refs.release ();
   chain->vars.release ();
   chain->inits.release ();
+  if (chain->init_seq)
+    gimple_seq_discard (chain->init_seq);
 
   free (chain);
 }
@@ -2457,7 +2462,7 @@ prepare_initializers_chain (struct loop *loop, chain_p chain)
 	}
 
       if (stmts)
-	gsi_insert_seq_on_edge_immediate (entry, stmts);
+	gimple_seq_add_seq (&chain->init_seq, stmts);
 
       chain->inits[i] = init;
     }
@@ -2487,6 +2492,22 @@ prepare_initializers (struct loop *loop, vec<chain_p> chains)
     }
 }
 
+/* Insert all initializing gimple stmts into loop's entry edge.  */
+
+static void
+insert_init_seqs (struct loop *loop, vec<chain_p> chains)
+{
+  unsigned i;
+  edge entry = loop_preheader_edge (loop);
+
+  for (i = 0; i < chains.length (); ++i)
+    if (chains[i]->init_seq)
+      {
+	gsi_insert_seq_on_edge_immediate (entry, chains[i]->init_seq);
+	chains[i]->init_seq = NULL;
+      }
+}
+
 /* Performs predictive commoning for LOOP.  Returns true if LOOP was
    unrolled.  */
 
@@ -2568,6 +2589,8 @@ tree_predictive_commoning_loop (struct loop *loop)
   /* Try to combine the chains that are always worked with together.  */
   try_combine_chains (&chains);
 
+  insert_init_seqs (loop, chains);
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "Before commoning:\n\n");
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]