+2017-07-28 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.
+ (insert_init_seqs): New function.
+ (tree_predictive_commoning_loop): Call insert_init_seqs.
+
2017-07-28 Bin Cheng <bin.cheng@arm.com>
* tree-predcom.c (determine_roots_comp): Skip trivial components.
/* 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;
chain->refs.release ();
chain->vars.release ();
chain->inits.release ();
+ if (chain->init_seq)
+ gimple_seq_discard (chain->init_seq);
free (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;
}
}
}
+/* 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. */
/* 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");