[4/6] OpenMP: Tweak NOP handling in in omp_get_root_term and accumulate_sibling_list

Message ID fb9af34bdb5a621cbc2ce200adeede49746cc513.1654107784.git.julian@codesourcery.com
State New
Headers
Series OpenMP 5.0: Fortran "declare mapper" support |

Commit Message

Julian Brown June 1, 2022, 6:39 p.m. UTC
  This patch strips NOPs in omp_get_root_term and accumulate_sibling_list
to cover cases that came up writing tests for "omp declare mapper"
functionality. I'll fold this into the originating patch series for
those functions during rework.

2022-06-01  Julian Brown  <julian@codesourcery.com>

gcc/
	* gimplify.cc (omp_get_root_term): Look through NOP_EXPRs.
	(accumulate_sibling_list): Strip NOPs on struct base pointers.
---
 gcc/gimplify.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 1646fdaa9b8..742fd5e4a8d 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -8775,7 +8775,8 @@  omp_get_root_term (tree expr)
 	 || (TREE_CODE (expr) == MEM_REF
 	     && integer_zerop (TREE_OPERAND (expr, 1)))
 	 || TREE_CODE (expr) == POINTER_PLUS_EXPR
-	 || TREE_CODE (expr) == COMPOUND_EXPR)
+	 || TREE_CODE (expr) == COMPOUND_EXPR
+	 || TREE_CODE (expr) == NOP_EXPR)
       if (TREE_CODE (expr) == COMPOUND_EXPR)
 	expr = TREE_OPERAND (expr, 1);
       else
@@ -9932,6 +9933,8 @@  accumulate_sibling_list (enum omp_region_type region_type, enum tree_code code,
 	    sdecl = TREE_OPERAND (sdecl, 0);
 	}
 
+      STRIP_NOPS (sdecl);
+
       while (TREE_CODE (sdecl) == POINTER_PLUS_EXPR)
 	sdecl = TREE_OPERAND (sdecl, 0);