Hi!

On 2021-08-12T22:48:33+0200, Jakub Jelinek via Gcc-patches 
<gcc-patches@gcc.gnu.org> wrote:
> The patch also contains something I should have done much earlier,

... and as its own commit...  ;-|

> for clauses that accept some integral expression where we only care
> about the value, forces during gimplification that value into
> either a min invariant (as before), SSA_NAME or a fresh temporary,
> but never e.g. a user VAR_DECL, so that for those clauses we don't
> need to worry about adjusting it.

> --- gcc/gimplify.c.jj 2021-08-11 23:43:45.897077306 +0200
> +++ gcc/gimplify.c    2021-08-12 14:47:57.451971003 +0200

> @@ -10110,9 +10112,20 @@ gimplify_scan_omp_clauses (tree *list_p,
>       case OMP_CLAUSE_VECTOR_LENGTH:
>       case OMP_CLAUSE_WORKER:
>       case OMP_CLAUSE_VECTOR:
> -       if (gimplify_expr (&OMP_CLAUSE_OPERAND (c, 0), pre_p, NULL,
> -                          is_gimple_val, fb_rvalue) == GS_ERROR)
> -         remove = true;
> +       if (OMP_CLAUSE_OPERAND (c, 0)
> +           && !is_gimple_min_invariant (OMP_CLAUSE_OPERAND (c, 0)))
> +         {
> +           if (error_operand_p (OMP_CLAUSE_OPERAND (c, 0)))
> +             {
> +               remove = true;
> +               break;
> +             }
> +           /* All these clauses care about value, not a particular decl,
> +              so try to force it into a SSA_NAME or fresh temporary.  */
> +           OMP_CLAUSE_OPERAND (c, 0)
> +             = get_initialized_tmp_var (OMP_CLAUSE_OPERAND (c, 0),
> +                                        pre_p, NULL, true);
> +         }
>         break;

In addition to the adjustments included here:

> --- gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c.jj    2020-07-28 
> 15:39:09.990756475 +0200
> +++ gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c       2021-08-12 
> 15:01:31.299065897 +0200

> -/* { dg-excess-errors "PR70392" { xfail c++ } } */

(I set the PR as resolved.)

> -  #pragma acc parallel if(b) /* { dg-warning "is used uninitialized" "" { 
> xfail c++ } } */
> +  #pragma acc parallel if(b) /* { dg-warning "is used uninitialized" } */
> [...]

> --- gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95.jj     2020-01-12 
> 11:54:38.237385890 +0100
> +++ gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95        2021-08-12 
> 15:04:02.269980316 +0200

> -  ! { dg-final { scan-tree-dump-times "(?n)#pragma omp target oacc_host_data 
> use_device_ptr\\(p\\) if\\(D\\.\[0-9\]+\\)$" 1 "gimple" } }
> +  ! { dg-final { scan-tree-dump-times "(?n)#pragma omp target oacc_host_data 
> use_device_ptr\\(p\\) if\\((?:D\\.|_)\[0-9\]+\\)$" 1 "gimple" } }

> -  ! { dg-final { scan-tree-dump-times "(?n)#pragma omp target oacc_host_data 
> use_device_ptr\\(if_present:p\\) if\\(D\\.\[0-9\]+\\) if_present$" 1 "gimple" 
> } }
> +  ! { dg-final { scan-tree-dump-times "(?n)#pragma omp target oacc_host_data 
> use_device_ptr\\(if_present:p\\) if\\((?:D\\.|_)\[0-9\]+\\) if_present$" 1 
> "gimple" } }

> --- gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95.jj       2021-04-19 
> 17:43:20.260417067 +0200
> +++ gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95  2021-08-12 
> 15:04:56.637229260 +0200

> -! { dg-final { scan-tree-dump-times {(?n)#pragma omp target 
> oacc_data_kernels if\(D\.[0-9]+\)$} 1 "omp_oacc_kernels_decompose" } }
> -! { dg-final { scan-tree-dump-times {(?n)#pragma omp target 
> oacc_parallel_kernels_gang_single num_gangs\(1\) if\(D\.[0-9]+\) 
> async\(-1\)$} 1 "omp_oacc_kernels_decompose" } }
> +! { dg-final { scan-tree-dump-times {(?n)#pragma omp target 
> oacc_data_kernels if\((?:D\.|_)[0-9]+\)$} 1 "omp_oacc_kernels_decompose" } }
> +! { dg-final { scan-tree-dump-times {(?n)#pragma omp target 
> oacc_parallel_kernels_gang_single num_gangs\(1\) if\((?:D\.|_)[0-9]+\) 
> async\(-1\)$} 1 "omp_oacc_kernels_decompose" } }

... we need to "Adjust 'libgomp.oacc-c-c++-common/static-variable-1.c'"
in (only) one case, too; pushed to master branch in
commit 2cc65fcbd470de8240f64317629a60fab879dfc5, see attached.

Non-offloading testing is only run with '-O2' but not '-O0'
('{ ! __OPTIMIZE__ }' selector); that's why you didn't see this, I
suppose.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
>From 2cc65fcbd470de8240f64317629a60fab879dfc5 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Fri, 13 Aug 2021 10:23:30 +0200
Subject: [PATCH] Adjust 'libgomp.oacc-c-c++-common/static-variable-1.c'

... for 'gcc/gimplify.c:gimplify_scan_omp_clauses' changes in recent
commit d0befed793b94f3f407be44e6f69f81a02f5f073 "openmp: Add support
for OpenMP 5.1 masked construct".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/static-variable-1.c: Adjust.
---
 .../testsuite/libgomp.oacc-c-c++-common/static-variable-1.c  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/static-variable-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/static-variable-1.c
index ceb2c88d3e5..69df0a6dd1d 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/static-variable-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/static-variable-1.c
@@ -298,7 +298,10 @@ static void t2(void)
 
 #pragma acc data \
   copy(results_1, results_2, results_3)
-  /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
+  /* { dg-note {variable 'num_gangs_request_1\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target { c && { ! __OPTIMIZE__ } } } .-2 } */
+  /* { dg-note {variable 'num_gangs_request_2\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target { c && { ! __OPTIMIZE__ } } } .-3 } */
+  /* { dg-note {variable 'num_gangs_request_3\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target { c && { ! __OPTIMIZE__ } } } .-4 } */
+  /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 } */
   {
     for (int i = 0; i < i_limit; ++i)
       {
-- 
2.30.2

Reply via email to