canonicalize_loop_ivs should add the IV bump in loop->header.
authorSebastian Pop <sebastian.pop@amd.com>
Wed, 31 Mar 2010 18:37:13 +0000 (18:37 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Wed, 31 Mar 2010 18:37:13 +0000 (18:37 +0000)
2010-03-16  Sebastian Pop  <sebastian.pop@amd.com>

* graphite-sese-to-poly.c (graphite_loop_normal_form): Add the IV bump
in loop->header.
* tree-flow.h (canonicalize_loop_ivs): Updated declaration.
* tree-parloops.c (gen_parallel_loop): Add the IV bump in loop->latch.
* tree-ssa-loop-manip.c (canonicalize_loop_ivs): Add a new parameter
to switch between adding the IV bump in loop->latch or in loop->header.

From-SVN: r157885

gcc/ChangeLog.graphite
gcc/graphite-sese-to-poly.c
gcc/tree-flow.h
gcc/tree-parloops.c
gcc/tree-ssa-loop-manip.c

index 26801bc9a7ddc266e4fe8e672d4dc2f1b1194abc..785ded35e048314a0445afdc312dcc33839c71d5 100644 (file)
@@ -1,3 +1,12 @@
+2010-03-16  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * graphite-sese-to-poly.c (graphite_loop_normal_form): Add the IV bump
+       in loop->header.
+       * tree-flow.h (canonicalize_loop_ivs): Updated declaration.
+       * tree-parloops.c (gen_parallel_loop): Add the IV bump in loop->latch.
+       * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Add a new parameter
+       to switch between adding the IV bump in loop->latch or in loop->header.
+
 2010-03-16  Sebastian Pop  <sebastian.pop@amd.com>
 
        * passes.c (init_optimization_passes): Add pass_copy_prop
index 83eff2a341cb2fcce3733c2d37758c19b5b497fd..d358137ef727cc9de19b318860db688577fee8ba 100644 (file)
@@ -2887,7 +2887,7 @@ graphite_loop_normal_form (loop_p loop)
 
   bool known_niter = number_of_iterations_exit (loop, exit, &niter, false);
 
-  /* At this point we should know the number of iterations,  */
+  /* At this point we should know the number of iterations.  */
   gcc_assert (known_niter);
 
   nit = force_gimple_operand (unshare_expr (niter.niter), &stmts, true,
@@ -2895,7 +2895,7 @@ graphite_loop_normal_form (loop_p loop)
   if (stmts)
     gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
 
-  loop->single_iv = canonicalize_loop_ivs (loop, &nit);
+  loop->single_iv = canonicalize_loop_ivs (loop, &nit, false);
 }
 
 /* Rewrite all the loops of SCOP in normal form: one induction
index e39658a78fb490e5c619bfb6b77553749ee4cf21..032ecaa04ddd88b576844c3e3245c5d412f9c7bb 100644 (file)
@@ -694,7 +694,7 @@ unsigned int tree_unroll_loops_completely (bool, bool);
 unsigned int tree_ssa_prefetch_arrays (void);
 void tree_ssa_iv_optimize (void);
 unsigned tree_predictive_commoning (void);
-tree canonicalize_loop_ivs (struct loop *, tree *);
+tree canonicalize_loop_ivs (struct loop *, tree *, bool);
 bool parallelize_loops (void);
 
 bool loop_only_exit_p (const struct loop *, const_edge);
index 885a713c7ceeb25c85e63ac4ff7414802661bb9d..35638315c9c7d642d9d64cdbf68fad46ddd79f4c 100644 (file)
@@ -1626,7 +1626,7 @@ gen_parallel_loop (struct loop *loop, htab_t reduction_list,
   free_original_copy_tables ();
 
   /* Base all the induction variables in LOOP on a single control one.  */
-  canonicalize_loop_ivs (loop, &nit);
+  canonicalize_loop_ivs (loop, &nit, true);
 
   /* Ensure that the exit condition is the first statement in the loop.  */
   transform_to_exit_first_loop (loop, reduction_list, nit);
index 7c54c87e74ff516f5e3ad3c636efcc5d61ceb986..7818f5b4f1acb1f57525ea8bd34f83f4254f54bb 100644 (file)
@@ -1181,11 +1181,13 @@ rewrite_all_phi_nodes_with_iv (loop_p loop, tree main_iv)
    compared with *NIT.  When the IV type precision has to be larger
    than *NIT type precision, *NIT is converted to the larger type, the
    conversion code is inserted before the loop, and *NIT is updated to
-   the new definition.  The induction variable is incremented in the
-   loop latch.  Return the induction variable that was created.  */
+   the new definition.  When BUMP_IN_LATCH is true, the induction
+   variable is incremented in the loop latch, otherwise it is
+   incremented in the loop header.  Return the induction variable that
+   was created.  */
 
 tree
-canonicalize_loop_ivs (struct loop *loop, tree *nit)
+canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
 {
   unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
   unsigned original_precision = precision;
@@ -1215,9 +1217,9 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit)
        gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
     }
 
-  gsi = gsi_last_bb (loop->latch);
+  gsi = gsi_last_bb (bump_in_latch ? loop->latch : loop->header);
   create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
-            loop, &gsi, true, &var_before, NULL);
+            loop, &gsi, bump_in_latch, &var_before, NULL);
 
   rewrite_all_phi_nodes_with_iv (loop, var_before);