Patchwork [3/3] Loop flattening on loop-SSA.

login
register
mail settings
Submitter Sebastian Pop
Date Nov. 3, 2010, 5:25 p.m.
Message ID <AANLkTi=S=R6Hn2gtGGcDDFuMghHPv41W23rVpVnSaqDW@mail.gmail.com>
Download mbox | patch
Permalink /patch/70041/
State New
Headers show

Comments

Sebastian Pop - Nov. 3, 2010, 5:25 p.m.
On Wed, Nov 3, 2010 at 11:26, Nathan Froyd <froydnj@codesourcery.com> wrote:
> Why not just use VEC_safe_grow_cleared here?
> I think you could use FOR_EACH_VEC_ELT.

Here is the change on top of the previous patch.
Thanks for the suggestions,
Sebastian

Patch

diff --git a/gcc/tree-loop-flattening.c b/gcc/tree-loop-flattening.c
index 4bc8768..56211b4 100644
--- a/gcc/tree-loop-flattening.c
+++ b/gcc/tree-loop-flattening.c
@@ -390,7 +390,7 @@  add_missing_phi_nodes_1 (loop_p loop, gimple def_stmt)
       edge e;
       edge_iterator ei;
       tree res, zero, var;
-      gimple loop_phi, latch_phi, use_stmt;
+      gimple loop_phi, latch_phi, use_stmt, phi;
       imm_use_iterator uit;
       tree name = DEF_FROM_PTR (def_p);
       bool needs_update = false;
@@ -437,17 +437,14 @@  add_missing_phi_nodes_1 (loop_p loop, gimple def_stmt)
 	add_phi_arg (latch_phi, res, e, UNKNOWN_LOCATION);

       phis = VEC_alloc (gimple, heap, n_basic_blocks);
-      for (i = 0; i < n_basic_blocks; i++)
-	VEC_quick_push (gimple, phis, NULL);
+      VEC_safe_grow_cleared (gimple, heap, phis, n_basic_blocks);

       VEC_replace (gimple, phis, loop->latch->index, latch_phi);
       VEC_replace (gimple, phis, loop->header->index, loop_phi);
       add_missing_phi_nodes_2 (loop, name, name, phis);

-      for (i = 0; i < n_basic_blocks; i++)
+      FOR_EACH_VEC_ELT (gimple, phis, i, phi)
 	{
-	  gimple phi = VEC_index (gimple, phis, i);
-
 	  if (!phi)
 	    continue;