diff mbox series

[04/14] Revert "openmp: Handle C/C++ array reference base-pointers in array sections"

Message ID 8db32dad90f031f27674ee9913f8db04046fa6d6.1687201315.git.julian@codesourcery.com
State New
Headers show
Series OpenMP/OpenACC: map clause and OMP gimplify rework | expand

Commit Message

Julian Brown June 19, 2023, 9:17 p.m. UTC
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 mbox series

Patch

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;
-}