[PATCH] Handle "omp simd array" accesses in ifcvt_memrefs_wont_trap

Richard Biener rguenther@suse.de
Fri May 31 11:32:00 GMT 2019


On Fri, 31 May 2019, Jakub Jelinek wrote:

> On Fri, May 31, 2019 at 11:43:29AM +0200, Richard Biener wrote:
> > Hmm.  Is it enough to set TREE_THIS_NOTRAP on the ARRAY_REF instead?
> 
> That works too.
> 
> > At least it's documented the ARRAY_REF then isn't the issue.
> > As for conditional vs. unconditional I'm not so sure but automatic
> > vars are excepmted from that anyways?
> 
> Only if they are guaranteed not to have out of bound accesses.
> 
> Anyway, I'll go with this, those ARRAY_REFs indeed should never trap.

Thanks - a lot simpler indeed ;)

Richard.

> 2019-05-31  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* omp-low.c (lower_rec_simd_input_clauses): Set TREE_THIS_NOTRAP on
> 	ivar and lvar.
> 
> 	* gcc.dg/vect/vect-cond-12.c: New test.
> 
> --- gcc/omp-low.c.jj	2019-05-30 23:19:14.469931759 +0200
> +++ gcc/omp-low.c	2019-05-31 11:52:20.491195088 +0200
> @@ -3728,6 +3728,8 @@ lower_rec_simd_input_clauses (tree new_v
>  		     NULL_TREE, NULL_TREE);
>        lvar = build4 (ARRAY_REF, TREE_TYPE (new_var), avar, sctx->lane,
>  		     NULL_TREE, NULL_TREE);
> +      TREE_THIS_NOTRAP (ivar) = 1;
> +      TREE_THIS_NOTRAP (lvar) = 1;
>      }
>    if (DECL_P (new_var))
>      {
> --- gcc/testsuite/gcc.dg/vect/vect-cond-12.c.jj	2019-05-31 11:25:33.203577504 +0200
> +++ gcc/testsuite/gcc.dg/vect/vect-cond-12.c	2019-05-31 11:26:58.616174115 +0200
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-additional-options "-fopenmp-simd" } */
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_condition } } } */
> +
> +int x;
> +
> +void
> +foo (int *a)
> +{
> +  #pragma omp simd lastprivate (x)
> +  for (int i = 0; i < 1024; ++i)
> +    if (a[i])
> +      x = i;
> +}
> 
> 
> 	Jakub
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany;
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah; HRB 21284 (AG NÌrnberg)


More information about the Gcc-patches mailing list