openmp: Disable SSA form during gimplification on OMP_SIMD clauses and body [PR104757]
authorJakub Jelinek <jakub@redhat.com>
Thu, 3 Mar 2022 08:13:32 +0000 (09:13 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 3 Mar 2022 08:13:32 +0000 (09:13 +0100)
commit431414b5d934866af3f6415a56c35bb57b928fef
tree143d1be1efe063d8ae6834c8822aa279eaa19fef
parente6e6e0a97340068c90fe091482efbaacd6474754
openmp: Disable SSA form during gimplification on OMP_SIMD clauses and body [PR104757]

When offloading to nvptx is enabled, scan_omp_simd duplicates the simd
region including its clauses and body using inliner's
copy_gimple_seq_and_replace_locals.  That works nicely for decls, remaps
only those that are seen in the nested bind expr vars (i.e. local variables)
and doesn't remap other vars.  But for SSA_NAMEs it remaps them always, doesn't
know if their def stmt is outside of the simd (then it better shouldn't be remapped)
or inside of it (then it should) and without cfg/dominators that is pretty hard
to figure out (well, we could walk the region twice, once note SSA_NAMEs defined
by each stmt seen there and once do the remapping of only those visited SSA_NAMEs).

This patch uses a simpler way, disables temporarily into_ssa for the clauses and
body of each simd region; we already disable into_ssa e.g. in parallel/target/task
etc. regions through push_gimplify_context () but for simd we don't push
any gimplification context and appart from into_ssa I think we don't need it.

2022-03-03  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/104757
* gimplify.cc (gimplify_omp_loop): Call gimplify_expr rather than
gimplify_omp_for.
(gimplify_expr) <case OMP_SIMD>: Temporarily disable
gimplify_ctxp->into_ssa around call to gimplify_omp_for.

* gfortran.dg/gomp/pr104757.f90: New test.
* gcc.dg/gomp/pr104757.c: New test.
gcc/gimplify.cc
gcc/testsuite/gcc.dg/gomp/pr104757.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/pr104757.f90 [new file with mode: 0644]