[committed] [OG10] Re: Re: [Patch] [OpenMP, Fortran] Add structure/derived-type element mapping

Kwok Cheung Yeung kcy@codesourcery.com
Wed Aug 19 20:00:01 GMT 2020


> If I got my tracking right, the og10 commit
> 4677091db1aa9d2a52e4839812bd73f47cc5e421 "[OpenMP, Fortran] Add
> structure/derived-type element mapping" regresses:
> 
>     [-PASS:-]{+FAIL:+} gfortran.dg/goacc/pr70828.f90   -O   scan-tree-dump-times gimple "omp target oacc_data map\\(tofrom:MEM\\[\\(c_char \\*\\)_[0-9]+\\] \\[len: _[0-9]+\\]\\) map\\(alloc:data \\[pointer assign, b
>     ias: _[0-9]+\\]\\)" 1
>     [-PASS:-]{+FAIL:+} gfortran.dg/goacc/pr70828.f90   -O   scan-tree-dump-times gimple "omp target oacc_parallel map\\(force_present:MEM\\[\\(c_char \\*\\)D\\.[0-9]+\\] \\[len: D\\.[0-9]+\\]\\) map\\(alloc:data \\[
>     pointer assign, bias: D\\.[0-9]+\\]\\)" 1
>     PASS: gfortran.dg/goacc/pr70828.f90   -O  (test for excess errors)

The mapping in the Gimple dump has changed from:

     _6 = parm.0.data;
     ...
     #pragma omp target oacc_data map(tofrom:MEM[(c_char *)_6] [len: _5]) 
map(alloc:data [pointer assign, bias: _10])

to:

     _6 = parm.0.data;
     _7 = (integer(kind=8)) _6
     data.2_8 = (integer(kind=8)) &data;
     _9 = _7 - data.2_8;
     _10 = _9 / 4;
     ...
     #pragma omp target oacc_data map(tofrom:data[_10] [len: _5]) map(alloc:data 
[pointer assign, bias: _14])

i.e. It is now mapping the array data starting from the offset that parm.0.data 
is at relative to data, rather than from the memory at parm.0.data directly.

This is due to the change in array handling in this part of the patch:

        if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
-	ptr2 = build_fold_addr_expr (decl);
+	{
+	  tree offset;
+	  ptr2 = build_fold_addr_expr (decl);
+	  offset = fold_build2 (MINUS_EXPR, ptrdiff_type_node, ptr,
+				fold_convert (ptrdiff_type_node, ptr2));
+	  offset = build2 (TRUNC_DIV_EXPR, ptrdiff_type_node,
+			   offset, fold_convert (ptrdiff_type_node, elemsz));
+	  offset = build4_loc (input_location, ARRAY_REF,
+			       TREE_TYPE (TREE_TYPE (decl)),
+			       decl, offset, NULL_TREE, NULL_TREE);
+	  OMP_CLAUSE_DECL (node) = offset;
+	}

As this does not cause a change in program behaviour, I believe it is enough to 
just change the expected output in the testcase. I have committed the attached 
patch to the OG10 branch as 'obvious'.

Kwok
-------------- next part --------------
From 0b999612a0205da31e3948f67cc754e9208e85fb Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <kcy@codesourcery.com>
Date: Wed, 19 Aug 2020 12:50:42 -0700
Subject: [PATCH] Fix gfortran.dg/goacc/pr70828.f90 testcase

Array mapping was changed by the patch '[OpenMP, Fortran] Add
structure/derived-type element mapping'.

2020-08-19  Kwok Cheung Yeung  <kcy@codesourcery.com>

	gcc/testsuite/
	* gfortran.dg/goacc/pr70828.f90: Update expected output in Gimple
	dump.
---
 gcc/testsuite/ChangeLog.omp                 | 5 +++++
 gcc/testsuite/gfortran.dg/goacc/pr70828.f90 | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 19395cf..ffc8f63 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2020-08-19  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+	* gfortran.dg/goacc/pr70828.f90: Update expected output in Gimple
+	dump.
+
 2020-08-18  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr70828.f90 b/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
index 2e58120..fcfe086 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
@@ -18,5 +18,5 @@ program test
   !$acc end data
 end program test
 
-! { dg-final { scan-tree-dump-times "omp target oacc_data map\\(tofrom:MEM\\\[\\(c_char \\*\\)\_\[0-9\]+\\\] \\\[len: _\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: _\[0-9\]+\\\]\\)" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:MEM\\\[\\(c_char \\*\\)D\\.\[0-9\]+\\\] \\\[len: D\\.\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: D\\.\[0-9\]+\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "omp target oacc_data map\\(tofrom:data\\\[\_\[0-9\]+\\\] \\\[len: _\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: _\[0-9\]+\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:data\\\[D\\.\[0-9\]+\\\] \\\[len: D\\.\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: D\\.\[0-9\]+\\\]\\)" 1 "gimple" } }
-- 
2.8.1



More information about the Gcc-patches mailing list