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  <jul...@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(-)

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);
 
-- 
2.29.2

Reply via email to