[PATCH] openmp: Do not emit OMPT loop-end call with inscan
Paul-Antoine Arras <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
When the inscan modifier is present on a for construct, a call to GOMP_loop_end
(or one of its variants) is already emitted. The extra call to one of the
*_worksharing_end functions, enabled by -fopenmp-ompt, is therefore redundant.
gcc/ChangeLog:
* omp-expand.cc (expand_omp_for_static_nochunk): Do not emit
*_static_worksharing_end call with inscan modifier.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/scan-8.c: New test.
---
gcc/omp-expand.cc | 7 +++++--
gcc/testsuite/c-c++-common/gomp/scan-8.c | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/gomp/scan-8.c
diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc
index 0d801e0d68a..ed08aec9a9c 100644
--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -5610,7 +5610,10 @@ expand_omp_for_static_nochunk (struct omp_region *region,
}
gsi = gsi_last_nondebug_bb (exit_bb);
- if (flag_openmp_ompt)
+ if (flag_openmp_ompt
+ && !(fd->have_reductemp
+ || ((fd->have_pointer_condtemp || fd->have_scantemp)
+ && !fd->have_nonctrl_scantemp)))
{
/* Insert call to GOMP_*_static_worksharing_end at the end of exit_bb.
*/
@@ -6367,7 +6370,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
}
gsi = gsi_last_nondebug_bb (exit_bb);
- if (flag_openmp_ompt)
+ if (flag_openmp_ompt && !(fd->have_reductemp || fd->have_pointer_condtemp))
{
/* Insert call to GOMP_*_static_worksharing_end at the end of exit_bb.
*/
diff --git a/gcc/testsuite/c-c++-common/gomp/scan-8.c b/gcc/testsuite/c-c++-common/gomp/scan-8.c
new file mode 100644
index 00000000000..cff8c03b349
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/scan-8.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fopenmp-ompt -fdump-tree-ompexp" } */
+
+/* Check that an extra, OMPT variant of GOMP_loop_end is not emitted when the
+ inscan modifier is present on the for construct. */
+
+#define N 100
+
+void f(void) {
+ int a[N], b[N];
+ int x = 0;
+
+#pragma omp parallel for simd reduction(inscan, +: x)
+ for (int k = 0; k < N; k++) {
+ x += a[k];
+#pragma omp scan inclusive(x)
+ b[k] = x;
+ }
+}
+
+/* { dg-final { scan-tree-dump "__builtin_GOMP_loop_end_nowait \\(" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_GOMP_loop_end_nowait \\(\\);\[\t\n \]*__builtin_GOMP_loop_static_worksharing_end \\(\\);" "ompexp" } } */
--
2.53.0