From: Tom de Vries <Tom_deVries@mentor.com>
To: "gcc-patches@gnu.org" <gcc-patches@gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [patch] Add counter inits to zero_iter_bb in expand_omp_for_init_counts
Date: Thu, 01 Oct 2015 12:46:00 -0000 [thread overview]
Message-ID: <560D2B09.4020501@mentor.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 320 bytes --]
Hi,
this patch adds initialization in zero_iter_bb of counters introduced in
expand_omp_for_init_counts.
This removes the need to set TREE_NO_WARNING on those counters.
Build on x86_64 and reg-tested with gomp.exp and target-libgomp c.exp.
OK for trunk, if bootstrap and reg-test on x86_64 succeeds?
Thanks,
- Tom
[-- Attachment #2: 0001-Add-counter-inits-to-zero_iter_bb-in-expand_omp_for_.patch --]
[-- Type: text/x-patch, Size: 3430 bytes --]
Add counter inits to zero_iter_bb in expand_omp_for_init_counts
2015-10-01 Tom de Vries <tom@codesourcery.com>
* omp-low.c (expand_omp_for_init_counts): Add inits for counters in
zero_iter_bb.
(expand_omp_for_generic): Remove TREE_NO_WARNING setttings on counters.
* gcc.dg/gomp/collapse-2.c: New test.
---
gcc/omp-low.c | 26 +++++++++++++++++++-------
gcc/testsuite/gcc.dg/gomp/collapse-2.c | 19 +++++++++++++++++++
2 files changed, 38 insertions(+), 7 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/gomp/collapse-2.c
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 8bcad08..8181757 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -5732,6 +5732,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
return;
}
+ bool created_zero_iter_bb = false;
for (i = 0; i < fd->collapse; i++)
{
tree itype = TREE_TYPE (fd->loops[i].v);
@@ -5774,6 +5775,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
gsi_insert_before (gsi, assign_stmt, GSI_SAME_STMT);
set_immediate_dominator (CDI_DOMINATORS, zero_iter_bb,
entry_bb);
+ created_zero_iter_bb = true;
}
ne = make_edge (entry_bb, zero_iter_bb, EDGE_FALSE_VALUE);
ne->probability = REG_BR_PROB_BASE / 2000 - 1;
@@ -5826,6 +5828,23 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
expand_omp_build_assign (gsi, fd->loop.n2, t);
}
}
+
+ if (created_zero_iter_bb)
+ {
+ gimple_stmt_iterator gsi = gsi_after_labels (zero_iter_bb);
+ /* Atm counts[0] doesn't seem to be used beyond create_zero_iter_bb,
+ but for robustness-sake we include that one as well. */
+ for (i = 0; i < fd->collapse; i++)
+ {
+ tree var = counts[i];
+ if (!SSA_VAR_P (var))
+ continue;
+
+ tree zero = build_zero_cst (type);
+ gassign *assign_stmt = gimple_build_assign (var, zero);
+ gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
+ }
+ }
}
@@ -6116,7 +6135,6 @@ expand_omp_for_generic (struct omp_region *region,
bool broken_loop = region->cont == NULL;
edge e, ne;
tree *counts = NULL;
- int i;
gcc_assert (!broken_loop || !in_combined_parallel);
gcc_assert (fd->iter_type == long_integer_type_node
@@ -6185,12 +6203,6 @@ expand_omp_for_generic (struct omp_region *region,
if (zero_iter_bb)
{
- /* Some counts[i] vars might be uninitialized if
- some loop has zero iterations. But the body shouldn't
- be executed in that case, so just avoid uninit warnings. */
- for (i = first_zero_iter; i < fd->collapse; i++)
- if (SSA_VAR_P (counts[i]))
- TREE_NO_WARNING (counts[i]) = 1;
gsi_prev (&gsi);
e = split_block (entry_bb, gsi_stmt (gsi));
entry_bb = e->dest;
diff --git a/gcc/testsuite/gcc.dg/gomp/collapse-2.c b/gcc/testsuite/gcc.dg/gomp/collapse-2.c
new file mode 100644
index 0000000..5319f89
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/collapse-2.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -fdump-tree-ssa" } */
+
+#define N 100
+
+int a[N][N];
+
+void
+foo (int m, int n)
+{
+ int i, j;
+#pragma omp parallel
+#pragma omp for collapse(2) schedule (runtime)
+ for (i = 0; i < m; i++)
+ for (j = 0; j < n; j++)
+ a[i][j] = 1;
+}
+
+/* { dg-final { scan-tree-dump-not "(?n)PHI.*count.*\\(D\\)" "ssa" } } */
--
1.9.1
next reply other threads:[~2015-10-01 12:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 12:46 Tom de Vries [this message]
2015-10-01 12:49 ` Jakub Jelinek
2015-10-01 13:38 ` Tom de Vries
2015-10-08 8:33 ` [gomp4, committed] " Tom de Vries
2015-10-23 14:40 ` [patch] " Thomas Schwinge
2015-10-28 9:50 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=560D2B09.4020501@mentor.com \
--to=tom_devries@mentor.com \
--cc=gcc-patches@gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).