On Tue, 8 Dec 2015, Tom de Vries wrote:

> Hi,
> 
> this patch fixes PR68640.
> 
> Consider this testcase:
> ...
> int
> foo (int *__restrict__ ap)
> {
>   int *bp = ap;
> #pragma omp parallel for
>   for (unsigned int idx = 0; idx < N; idx++)
>     ap[idx] = bp[idx];
> }
> ...
> 
> When declaring a field for restrict pointer ap in the data passing struct for
> the thread function, we declare that field with restrict.
> 
> So, we roughly get the equivalent of:
> ...
> foo.omp_fn (int *restrict ap, int *bp)
> {
>   for (unsigned int idx = 0; idx < N; idx++)
>     ap[idx] = bp[idx];
> }
> 
> int
> foo (int *__restrict__ ap)
> {
>   int *bp = ap;
>   GOMP_parallel (foo.omp_fn, ap, bp, ...);
> }
> ...
> 
> That is incorrect, since ap is not restrict in thread function foo.omp_fn,
> given that we also access *ap via bp.
> 
> Atm, this doesn't result in wrong code, but it might result in wrong code when
> we make restrict interpretation more aggressive.
> 
> The patch fixes the problem by clearing the restrict qualifier on pointer
> types in install_var_field.
> 
> Build non-bootstrap c compiler and tested gcc/gomp.exp and
> target-libgomp/c.exp.
> 
> OK for stage3 trunk if bootstrap and reg-test succeeds?

Ok.

Richard.

> Thanks,
> - Tom
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to