OpenMP: Ignore side-effects when finding struct comps [PR108545]
authorTobias Burnus <tobias@codesourcery.com>
Wed, 1 Mar 2023 14:11:53 +0000 (15:11 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 1 Mar 2023 14:24:36 +0000 (15:24 +0100)
commit3843dc1460259fbca1f336b0259f0b6b527d77ae
tree91c22dcf53dde512f6f7c8b868bee57bcc7c0b4f
parent070523b9d4c6cfa69060255893006efaf39bf617
OpenMP: Ignore side-effects when finding struct comps [PR108545]

With volatile, two 'x.data' comp refs aren't regarded as identical,
causing that the two items in the first map of
  map(to:x.a, x.a.data) map(pset: x.a.data)
end up in separate 'map(struct:x)', which will cause a later ICE.

Solution: Ignore side effects when checking the operands in the hash
for being equal. (Do so by creating a variant of tree_operand_hash
that calls operand_equal_p with OEP_MATCH_SIDE_EFFECTS.)

gcc/ChangeLog:

PR middle-end/108545
* gimplify.cc (struct tree_operand_hash_no_se): New.
(omp_index_mapping_groups_1, omp_index_mapping_groups,
omp_reindex_mapping_groups, omp_mapped_by_containing_struct,
omp_tsort_mapping_groups_1, omp_tsort_mapping_groups,
oacc_resolve_clause_dependencies, omp_build_struct_sibling_lists,
gimplify_scan_omp_clauses): Use tree_operand_hash_no_se instead
of tree_operand_hash.

gcc/testsuite/ChangeLog:

PR middle-end/108545
* c-c++-common/gomp/map-8.c: New test.
* gfortran.dg/gomp/map-9.f90: New test.
gcc/gimplify.cc
gcc/testsuite/c-c++-common/gomp/map-8.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/map-9.f90 [new file with mode: 0644]