[PATCH, PR68373 ] Call scev_const_prop in pass_parallelize_loops::execute
Tom de Vries
Thu Nov 19 09:36:00 GMT 2015
On 17/11/15 23:20, Tom de Vries wrote:
> [ was: Re: [PATCH, 10/16] Add pass_oacc_kernels pass group in passes.def ]
> Consider test-case test.c, with a use of the final value of the
> iteration variable (return i):
> unsigned int
> foo (int *a, unsigned int n)
> unsigned int i;
> for (i = 0; i < n; ++i)
> a[i] = 1;
> return i;
> Compiled with:
> $ gcc -S -O2 test.c -ftree-parallelize-loops=2 -fdump-tree-all-details
> Before parloops, we have:
> <bb 4>:
> # i_12 = PHI <0(3), i_10(5)>
> _5 = (long unsigned int) i_12;
> _6 = _5 * 4;
> _8 = a_7(D) + _6;
> *_8 = 1;
> i_10 = i_12 + 1;
> if (n_4(D) > i_10)
> goto <bb 5>;
> goto <bb 6>;
> <bb 5>:
> goto <bb 4>;
> <bb 6>:
> # i_14 = PHI <n_4(D)(4), 0(2)>
> Parloops will fail because:
> phi is n_2 = PHI <n_4(D)(4)>
> arg of phi to exit: value n_4(D) used outside loop
> checking if it a part of reduction pattern:
> FAILED: it is not a part of reduction....
> [ note that the phi looks slightly different. In
> gather_scalar_reductions -> vect_analyze_loop_form ->
> vect_analyze_loop_form_1 -> split_loop_exit_edge we split the edge from
> bb4 to bb6. ]
> This patch uses scev_const_prop at the start of parloops.
> scev_const_prop first also splits the exit edge, and then replaces the
> phi with a assignment:
> final value replacement:
> n_2 = PHI <n_4(D)(4)>
> n_2 = n_4(D);
> This allows parloops to succeed.
> And there's a similar story when we compile with -fno-tree-scev-cprop in
> Bootstrapped and reg-tested on x86_64.
> OK for stage3/stage1?
The patch has been updated to do the final value replacement only for
the loop that parloops is processing, as suggested in review comment at
That means the patch is now also required for the kernels patch series.
Bootstrapped and reg-tested on x86_64.
OK for stage 3 trunk?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 10690 bytes
Desc: not available
More information about the Gcc-patches