diff mbox

Mark by_ref mem_ref in build_receiver_ref as non-trapping

Message ID 5650B91A.8030107@mentor.com
State New
Headers show

Commit Message

Tom de Vries Nov. 21, 2015, 6:34 p.m. UTC
[ was: Re: [Committed] Mark *.omp_data_i as non-trapping ]

On 13/07/15 11:49, Tom de Vries wrote:
> [ was: Re: [gomp4, committed] Handle nested loops in kernels regions ]
>
> On 13/07/15 10:36, Jakub Jelinek wrote:
>> On Mon, Jul 13, 2015 at 10:19:56AM +0200, Thomas Schwinge wrote:
>>>> We rely on pass_lim to move the *.omp_data_i loads out of the loop
>>>> nest.
>>>> For the test-case, pass_lim was managing to move the load out of the
>>>> inner loop, but not the outer loop, because the load was classified as
>>>> 'MOVE_PRESERVE_EXECUTION'. By marking the *.omp_data_i load
>>>> non-trapping, it's now classified as 'MOVE_POSSIBLE', and moved out of
>>>> the loop nest.

This follow-up patch also marks the 'by_ref' mem_ref in 
build_receiver_ref as non-trapping.

Bootstrapped and reg-tested on x86_64.

OK for stage3 (because it's needed for the oacc kernels support)?

Thanks,
- Tom

Comments

Jakub Jelinek Nov. 23, 2015, 8:45 a.m. UTC | #1
On Sat, Nov 21, 2015 at 07:34:02PM +0100, Tom de Vries wrote:
> Mark by_ref mem_ref in build_receiver_ref as non-trapping
> 
> 2015-11-21  Tom de Vries  <tom@codesourcery.com>
> 
> 	* omp-low.c (build_receiver_ref): Mark by_ref mem_ref as non-trapping.

This is ok.
> 
> ---
>  gcc/omp-low.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index 830db75..78f2853 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -1249,7 +1249,10 @@ build_receiver_ref (tree var, bool by_ref, omp_context *ctx)
>    TREE_THIS_NOTRAP (x) = 1;
>    x = omp_build_component_ref (x, field);
>    if (by_ref)
> -    x = build_simple_mem_ref (x);
> +    {
> +      x = build_simple_mem_ref (x);
> +      TREE_THIS_NOTRAP (x) = 1;
> +    }
>  
>    return x;
>  }


	Jakub
Richard Biener Nov. 23, 2015, 10:39 a.m. UTC | #2
On Mon, Nov 23, 2015 at 9:45 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sat, Nov 21, 2015 at 07:34:02PM +0100, Tom de Vries wrote:
>> Mark by_ref mem_ref in build_receiver_ref as non-trapping
>>
>> 2015-11-21  Tom de Vries  <tom@codesourcery.com>
>>
>>       * omp-low.c (build_receiver_ref): Mark by_ref mem_ref as non-trapping.
>
> This is ok.

Are you sure this is properly re-set by inlining via

          /* We cannot propagate the TREE_THIS_NOTRAP flag if we have
             remapped a parameter as the property might be valid only
             for the parameter itself.  */
          if (TREE_THIS_NOTRAP (old)
              && (!is_parm (TREE_OPERAND (old, 0))
                  || (!id->transform_parameter && is_parm (ptr))))
            TREE_THIS_NOTRAP (*tp) = 1;

?  Or is this never hoistable to a place where TREE_THIS_NOTRAP is not true
even after inlining?  (I presume this is not directly a load via the
static chain pointer?)

>>
>> ---
>>  gcc/omp-low.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
>> index 830db75..78f2853 100644
>> --- a/gcc/omp-low.c
>> +++ b/gcc/omp-low.c
>> @@ -1249,7 +1249,10 @@ build_receiver_ref (tree var, bool by_ref, omp_context *ctx)
>>    TREE_THIS_NOTRAP (x) = 1;
>>    x = omp_build_component_ref (x, field);
>>    if (by_ref)
>> -    x = build_simple_mem_ref (x);
>> +    {
>> +      x = build_simple_mem_ref (x);
>> +      TREE_THIS_NOTRAP (x) = 1;
>> +    }
>>
>>    return x;
>>  }
>
>
>         Jakub
Jakub Jelinek Nov. 23, 2015, 10:54 a.m. UTC | #3
On Mon, Nov 23, 2015 at 11:39:26AM +0100, Richard Biener wrote:
> On Mon, Nov 23, 2015 at 9:45 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Sat, Nov 21, 2015 at 07:34:02PM +0100, Tom de Vries wrote:
> >> Mark by_ref mem_ref in build_receiver_ref as non-trapping
> >>
> >> 2015-11-21  Tom de Vries  <tom@codesourcery.com>
> >>
> >>       * omp-low.c (build_receiver_ref): Mark by_ref mem_ref as non-trapping.
> >
> > This is ok.
> 
> Are you sure this is properly re-set by inlining via
> 
>           /* We cannot propagate the TREE_THIS_NOTRAP flag if we have
>              remapped a parameter as the property might be valid only
>              for the parameter itself.  */
>           if (TREE_THIS_NOTRAP (old)
>               && (!is_parm (TREE_OPERAND (old, 0))
>                   || (!id->transform_parameter && is_parm (ptr))))
>             TREE_THIS_NOTRAP (*tp) = 1;
> 
> ?  Or is this never hoistable to a place where TREE_THIS_NOTRAP is not true
> even after inlining?  (I presume this is not directly a load via the
> static chain pointer?)

I don't think inlining is ever around here, this is inside of the outlined
bodies of the OpenMP constructs, those are the *.omp_fn* artificial
functions called from libgomp, and is used in cases where
  .omp_data_i->field
is not the field itself, but pointer to the original variable.  The caller
of the libgomp functions that in the end invoke the .omp_fn* functions
guarantees that the field in that case is initialized to an address of the
original variables, is not NULL or some invalid pointer.

	Jakub
diff mbox

Patch

Mark by_ref mem_ref in build_receiver_ref as non-trapping

2015-11-21  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (build_receiver_ref): Mark by_ref mem_ref as non-trapping.

---
 gcc/omp-low.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 830db75..78f2853 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1249,7 +1249,10 @@  build_receiver_ref (tree var, bool by_ref, omp_context *ctx)
   TREE_THIS_NOTRAP (x) = 1;
   x = omp_build_component_ref (x, field);
   if (by_ref)
-    x = build_simple_mem_ref (x);
+    {
+      x = build_simple_mem_ref (x);
+      TREE_THIS_NOTRAP (x) = 1;
+    }
 
   return x;
 }