public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, <jakub@redhat.com>, <tobias@codesourcery.com>
Subject: [PATCH 04/14] Revert "openmp: Handle C/C++ array reference base-pointers in array sections"
Date: Mon, 19 Jun 2023 21:17:28 +0000	[thread overview]
Message-ID: <8db32dad90f031f27674ee9913f8db04046fa6d6.1687201315.git.julian@codesourcery.com> (raw)
In-Reply-To: <cover.1687201315.git.julian@codesourcery.com>

This reverts commit 3385743fd2fa15a2a750a29daf6d4f97f5aad0ae.

2023-06-16  Julian Brown  <julian@codesourcery.com>

Revert:
	2022-02-24  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/c/ChangeLog:

	* c-typeck.cc (handle_omp_array_sections): Add handling for
	creating array-reference base-pointer attachment clause.

gcc/cp/ChangeLog:

	* semantics.cc (handle_omp_array_sections): Add handling for
	creating array-reference base-pointer attachment clause.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/target-enter-data-1.c: Adjust testcase.

libgomp/ChangeLog:

	* testsuite/libgomp.c-c++-common/ptr-attach-2.c: New test.
---
 gcc/c/c-typeck.cc                             | 27 +--------
 gcc/cp/semantics.cc                           | 28 +--------
 .../c-c++-common/gomp/target-enter-data-1.c   |  3 +-
 .../libgomp.c-c++-common/ptr-attach-2.c       | 60 -------------------
 4 files changed, 3 insertions(+), 115 deletions(-)
 delete mode 100644 libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 450214556f9..9591d67251e 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -14113,10 +14113,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
 	maybe_zero_len = true;
 
-      struct dim { tree low_bound, length; };
-      auto_vec<dim> dims (num);
-      dims.safe_grow (num);
-
       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
 	   t = TREE_CHAIN (t))
 	{
@@ -14238,9 +14234,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	      else
 		size = size_binop (MULT_EXPR, size, l);
 	    }
-
-	  dim d = { low_bound, length };
-	  dims[i] = d;
 	}
       if (non_contiguous)
 	{
@@ -14288,23 +14281,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	  OMP_CLAUSE_DECL (c) = t;
 	  return false;
 	}
-
-      tree aref = t;
-      for (i = 0; i < dims.length (); i++)
-	{
-	  if (dims[i].length && integer_onep (dims[i].length))
-	    {
-	      tree lb = dims[i].low_bound;
-	      aref = build_array_ref (OMP_CLAUSE_LOCATION (c), aref, lb);
-	    }
-	  else
-	    {
-	      if (TREE_CODE (TREE_TYPE (aref)) == POINTER_TYPE)
-		t = aref;
-	      break;
-	    }
-	}
-
       first = c_fully_fold (first, false, NULL);
       OMP_CLAUSE_DECL (c) = first;
       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
@@ -14339,8 +14315,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	  break;
 	}
       tree c2 = build_omp_clause (OMP_CLAUSE_LOCATION (c), OMP_CLAUSE_MAP);
-      if (TREE_CODE (t) == COMPONENT_REF || TREE_CODE (t) == ARRAY_REF
-	  || TREE_CODE (t) == INDIRECT_REF)
+      if (TREE_CODE (t) == COMPONENT_REF)
 	OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_ATTACH_DETACH);
       else
 	OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER);
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index e7bda6fa060..93ff7cf5e1b 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -5605,10 +5605,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
       if (processing_template_decl && maybe_zero_len)
 	return false;
 
-      struct dim { tree low_bound, length; };
-      auto_vec<dim> dims (num);
-      dims.safe_grow (num);
-
       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
 	   t = TREE_CHAIN (t))
 	{
@@ -5728,9 +5724,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	      else
 		size = size_binop (MULT_EXPR, size, l);
 	    }
-
-	  dim d = { low_bound, length };
-	  dims[i] = d;
 	}
       if (!processing_template_decl)
 	{
@@ -5782,24 +5775,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	      OMP_CLAUSE_DECL (c) = t;
 	      return false;
 	    }
-
-	  tree aref = t;
-	  for (i = 0; i < dims.length (); i++)
-	    {
-	      if (dims[i].length && integer_onep (dims[i].length))
-		{
-		  tree lb = dims[i].low_bound;
-		  aref = convert_from_reference (aref);
-		  aref = build_array_ref (OMP_CLAUSE_LOCATION (c), aref, lb);
-		}
-	      else
-		{
-		  if (TREE_CODE (TREE_TYPE (aref)) == POINTER_TYPE)
-		    t = aref;
-		  break;
-		}
-	    }
-
 	  OMP_CLAUSE_DECL (c) = first;
 	  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
 	    return false;
@@ -5841,8 +5816,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
 	  bool reference_always_pointer = true;
 	  tree c2 = build_omp_clause (OMP_CLAUSE_LOCATION (c),
 				      OMP_CLAUSE_MAP);
-	  if (TREE_CODE (t) == COMPONENT_REF || TREE_CODE (t) == ARRAY_REF
-	      || (TREE_CODE (t) == INDIRECT_REF && !REFERENCE_REF_P (t)))
+	  if (TREE_CODE (t) == COMPONENT_REF)
 	    {
 	      OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_ATTACH_DETACH);
 
diff --git a/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c b/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c
index 3a1b488fa1f..ce766d29e2d 100644
--- a/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c
@@ -21,5 +21,4 @@ void func (struct foo *f, int n, int m)
   #pragma omp target enter data map (to: f->bars[n].vectors[:f->bars[n].num_vectors])
 }
 
-/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\\*_\[0-9\]+ \\\[bias: \[^\]\]+\\\]\\)" 1 "gimple" } } */
-/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\[^-\]+->vectors \\\[bias: \[^\]\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\[^-\]+->vectors \\\[bias: \[^\]\]+\\\]\\)" 3 "gimple" } } */
diff --git a/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c b/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c
deleted file mode 100644
index 889a4a253ae..00000000000
--- a/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stdlib.h>
-
-struct blk { int x, y; };
-struct L
-{
-  #define N 10
-  struct {
-    int num_blocks[N];
-    struct blk * blocks[N];
-  } m;
-};
-
-void foo (struct L *l)
-{
-  for (int i = 0; i < N; i++)
-    {
-      l->m.blocks[i] = (struct blk *) malloc (sizeof (struct blk) * N);
-      l->m.num_blocks[i] = N;
-    }
-
-  #pragma omp target enter data map(to:l[:1])
-  for (int i = 0; i < N; i++)
-    {
-      #pragma omp target enter data map(to:l->m.blocks[i][:l->m.num_blocks[i]])
-    }
-
-  #pragma omp target
-  {
-    for (int i = 0; i < N; i++)
-      for (int j = 0; j < N; j++)
-	{
-	  l->m.blocks[i][j].x = i + j;
-	  l->m.blocks[i][j].y = i * j;
-	}
-  }
-
-  for (int i = 0; i < N; i++)
-    {
-      #pragma omp target exit data map(from:l->m.blocks[i][:l->m.num_blocks[i]])
-    }
-  #pragma omp target exit data map(from:l[:1])
-
-
-  for (int i = 0; i < N; i++)
-    for (int j = 0; j < N; j++)
-      {
-	if (l->m.blocks[i][j].x != i + j)
-	  abort ();
-	if (l->m.blocks[i][j].y != i * j)
-	  abort ();
-      }
-
-}
-
-int main (void)
-{
-  struct L l;
-  foo (&l);
-  return 0;
-}
-- 
2.31.1


  parent reply	other threads:[~2023-06-19 21:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 21:17 [PATCH 00/14] [og13] OpenMP/OpenACC: map clause and OMP gimplify rework Julian Brown
2023-06-19 21:17 ` [PATCH 01/14] Revert "Assumed-size arrays with non-lexical data mappings" Julian Brown
2023-06-19 21:17 ` [PATCH 02/14] Revert "Fix references declared in lexically-enclosing OpenACC data region" Julian Brown
2023-06-19 21:17 ` [PATCH 03/14] Revert "Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)" Julian Brown
2023-06-19 21:17 ` Julian Brown [this message]
2023-06-19 21:17 ` [PATCH 05/14] OpenMP/OpenACC: Reindent TO/FROM/_CACHE_ stanza in {c_}finish_omp_clause Julian Brown
2023-06-19 21:17 ` [PATCH 06/14] OpenMP/OpenACC: Rework clause expansion and nested struct handling Julian Brown
2023-06-19 21:17 ` [PATCH 07/14] OpenMP: implicitly map base pointer for array-section pointer components Julian Brown
2023-06-19 21:17 ` [PATCH 08/14] OpenMP: Pointers and member mappings Julian Brown
2023-06-19 21:17 ` [PATCH 09/14] OpenMP/OpenACC: Unordered/non-constant component offset runtime diagnostic Julian Brown
2023-06-19 21:17 ` [PATCH 10/14] OpenMP/OpenACC: Reorganise OMP map clause handling in gimplify.cc Julian Brown
2023-06-19 21:17 ` [PATCH 11/14] OpenACC: Reimplement "inheritance" for lexically-nested offload regions Julian Brown
2023-06-19 21:17 ` [PATCH 12/14] OpenACC: "declare create" fixes wrt. "allocatable" variables Julian Brown
2023-06-19 21:17 ` [PATCH 13/14] OpenACC: Allow implicit uses of assumed-size arrays in offload regions Julian Brown
2023-06-19 21:17 ` [PATCH 14/14] OpenACC: Improve implicit mapping for non-lexically nested " Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8db32dad90f031f27674ee9913f8db04046fa6d6.1687201315.git.julian@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).