public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5262] openmp: Fix up OpenMP expansion of non-rectangular loops [PR108459] Date: Thu, 19 Jan 2023 20:02:37 +0000 (GMT) [thread overview] Message-ID: <20230119200237.1A75D3858C52@sourceware.org> (raw) https://gcc.gnu.org/g:46644ec99cb355845b23bb1d02775c057ed8ee88 commit r13-5262-g46644ec99cb355845b23bb1d02775c057ed8ee88 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 19 21:00:08 2023 +0100 openmp: Fix up OpenMP expansion of non-rectangular loops [PR108459] expand_omp_for_init_counts was using for the case where collapse(2) inner loop has init expression dependent on non-constant multiple of the outer iterator and the condition upper bound expression doesn't depend on the outer iterator fold_unary (NEGATE_EXPR, ...). This will just return NULL if it can't be folded, we need fold_build1 instead. 2023-01-19 Jakub Jelinek <jakub@redhat.com> PR middle-end/108459 * omp-expand.cc (expand_omp_for_init_counts): Use fold_build1 rather than fold_unary for NEGATE_EXPR. * testsuite/libgomp.c/pr108459.c: New test. Diff: --- gcc/omp-expand.cc | 4 ++-- libgomp/testsuite/libgomp.c/pr108459.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index c7ef41924d6..940454ba5b6 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -2003,8 +2003,8 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi, t = fold_build2 (MINUS_EXPR, itype, unshare_expr (fd->loops[i].m2), unshare_expr (fd->loops[i].m1)); else if (fd->loops[i].m1) - t = fold_unary (NEGATE_EXPR, itype, - unshare_expr (fd->loops[i].m1)); + t = fold_build1 (NEGATE_EXPR, itype, + unshare_expr (fd->loops[i].m1)); else t = unshare_expr (fd->loops[i].m2); tree m2minusm1 diff --git a/libgomp/testsuite/libgomp.c/pr108459.c b/libgomp/testsuite/libgomp.c/pr108459.c new file mode 100644 index 00000000000..87ce981e080 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr108459.c @@ -0,0 +1,41 @@ +/* PR middle-end/108459 */ + +char a[17][17]; + +__attribute__((noipa)) void +foo (int x, int y) +{ + #pragma omp for collapse(2) + for (int i = 1; i <= 16; i++) + for (int j = i * x + y; j <= 16; j++) + a[i][j] = 1; +} + +int +main () +{ + #pragma omp parallel + foo (1, 1); + for (int i = 0; i <= 16; i++) + for (int j = 0; j <= 16; j++) + if (i >= 1 && j >= i + 1) + { + if (a[i][j] != 1) + __builtin_abort (); + a[i][j] = 0; + } + else if (a[i][j]) + __builtin_abort (); + #pragma omp parallel + foo (2, -2); + for (int i = 0; i <= 16; i++) + for (int j = 0; j <= 16; j++) + if (i >= 1 && j >= 2 * i - 2) + { + if (a[i][j] != 1) + __builtin_abort (); + } + else if (a[i][j]) + __builtin_abort (); + return 0; +}
reply other threads:[~2023-01-19 20:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230119200237.1A75D3858C52@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).