diff options
author | Bin Cheng <bin.cheng@arm.com> | 2017-07-28 14:55:49 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-07-28 14:55:49 +0000 |
commit | aa4de160ccafb70787013aaa540375aaac0056da (patch) | |
tree | 4f3addcb36278c90de993717ebfab1dd576b524b /gcc/tree-predcom.c | |
parent | 67bb451dfbfbac87a1289ad4e9e38f7c2abf4d02 (diff) | |
download | gcc-aa4de160ccafb70787013aaa540375aaac0056da.zip gcc-aa4de160ccafb70787013aaa540375aaac0056da.tar.gz gcc-aa4de160ccafb70787013aaa540375aaac0056da.tar.bz2 |
tree-predcom.c (struct chain): New field init_seq.
* tree-predcom.c (struct chain): New field init_seq.
(release_chain): Release init_seq.
(prepare_initializers_chain): Record intialization stmts in above
field.
(insert_init_seqs): New function.
(tree_predictive_commoning_loop): Call insert_init_seqs.
From-SVN: r250666
Diffstat (limited to 'gcc/tree-predcom.c')
-rw-r--r-- | gcc/tree-predcom.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 536fe34..089d3c6 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_without_update (&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"); |