On Wed, Dec 18, 2013 at 03:29:04PM +0000, Iyer, Balaji V wrote: > > OpenMP also supports C++ iterators, so I don't see why you don't follow > > that. > > The iterators are lowered already by the C++ FE, what the middle-end sees is > > an integral iterator. Just look at one of the several > > libgomp/testsuite/libgomp.c++/for-* testcases. > > > > I think we are talking two different things or I am not understanding you. > I am using OMP's iterator handling mechanism, but the question I have is > about the pre-body. It is pre-gimplifying the condition and the initial > value and storing it in pre_body. The prebody is then pushed into the > child function. I want the pre-body to be pushed into main function. Is > it possible for me to do that?
Well, unless you are adding a parallel region around your GIMPLE_FOR variant explicitly, you'd automatically evaluate the pre_body before that. If you have an artificial parallel there, you need to take care about it e.g. during gimplification for your variant. What I was complaining about is: @@ -523,6 +524,12 @@ struct GTY(()) gimple_omp_for_iter { /* Increment. */ tree incr; + + /* Loop count, only used by _Cilk_for. */ + tree loop_count; + + /* Grain value, only used by _Cilk_for. */ + tree grain; }; /* GIMPLE_OMP_FOR */ Don't do this, compute loop count during omp expansion (there is already code that does that for you, after all, for #pragma omp for the loop count is typically (unless static schedule) passed as parameter to the runtime as well. And for grain really use an artificial clause, it can be called CILK_CLAUSE__GRAIN_ (similarly how we put _s around LOOPTEMP or SIMDUID clause names, those are also artificial clauses). Jakub