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] Merge to trunk from Graphite branch


On Tue, Mar 16, 2010 at 12:59, Sebastian Pop <sebpop@gmail.com> wrote:
> On Tue, Mar 16, 2010 at 08:24, Ira Rosen <IRAR@il.ibm.com> wrote:
>> In gas_dyn vectorization fails because Graphite inserts statements in latch
>> blocks, e.g. (line 409),
>>
>> <bb 12>:
>> ?# ivtmp.2047_274 = PHI <ivtmp.2047_275(13), 0(11)>
>> ?D.7535_276 = (integer(kind=8)) ivtmp.2047_274;
>> ?S.26_217 = D.7535_276 + 1;
>> ?D.4310_112 = S.26_217 + -1;
>> ?(*gamma_113(D))[D.4310_112] = D.4292_73;
>> ?if (ivtmp.2047_274 < D.7533_233)
>> ? ?goto <bb 13>;
>> ?else
>> ? ?goto <bb 14>;
>>
>> <bb 13>:
>> ?ivtmp.2047_275 = ivtmp.2047_274 + 1; ?<============= this statement
>> ?goto <bb 12>;
>>
>
> This is due to the fact that we call
>
> ?loop->single_iv = canonicalize_loop_ivs (loop, &nit);
>
> This function was used only after the vectorizer in parloops:
>
> $ grep canonicalize_loop_ivs *.[ch]
> graphite-sese-to-poly.c:2897: ?loop->single_iv = canonicalize_loop_ivs
> (loop, &nit);
> tree-flow.h:697:tree canonicalize_loop_ivs (struct loop *, tree *);
> tree-parloops.c:1629: ?canonicalize_loop_ivs (loop, &nit);
> tree-ssa-loop-manip.c:1188:canonicalize_loop_ivs (struct loop *loop, tree *nit)
>
> but now it is used in Graphite this should be cleaned up to not
> generate the iv bumping in the loop->latch.
>

With the attached patch we now get:

$ ./f951 -O3 -ffast-math -ftree-vectorizer-verbose=2
-fgraphite-identity gas_dyn.f90 &> before.txt
$ ./f951 -O3 -ffast-math -ftree-vectorizer-verbose=2
-fgraphite-identity gas_dyn.f90 &> after.txt

$ grep "LOOP VECTORIZED" before.txt | wc
     24      96    1848
$ grep "LOOP VECTORIZED" after.txt | wc
     40     160    3065

I will test this patch on amd64-linux.
Ok for trunk if it passes bootstrap and test?

Thanks,
Sebastian
From 0be713a0cc67d73e55f88c8c07e55a22c3ae62ee Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Tue, 16 Mar 2010 13:39:16 -0500
Subject: [PATCH] canonicalize_loop_ivs should add the IV bump in loop->header.

---
 gcc/graphite-sese-to-poly.c |    2 +-
 gcc/tree-ssa-loop-manip.c   |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index b0bc348..a016285 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2886,7 +2886,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,
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 7c54c87..9d5d697 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -1215,9 +1215,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 (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, false, &var_before, NULL);
 
   rewrite_all_phi_nodes_with_iv (loop, var_before);
 
-- 
1.6.3.3


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