public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/101167] New: Miscompilation of task_reduction
Date: Tue, 22 Jun 2021 17:41:40 +0000	[thread overview]
Message-ID: <bug-101167-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101167

            Bug ID: 101167
           Summary: Miscompilation of task_reduction
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: jakub at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

struct S { int a, b, c[2]; };

void
init (struct S *x)
{
  x->a = 0;
  x->b = 0;
  x->c[0] = 0;
  x->c[1] = 0;
}

void
merge (struct S *x, struct S *y)
{
  x->a += y->a;
  x->b += y->b;
}

#pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in))
initializer (init (&omp_priv))

void
foo (struct S x)
{
  #pragma omp taskgroup task_reduction (+: x)
  {
    #pragma omp task in_reduction (+: x)
    {
      x.a++;
      x.b++;
    }
    #pragma omp task in_reduction (+: x)
    {
      x.a += 4;
      x.b += 14;
    }
    #pragma omp task in_reduction (+: x)
    {
      x.a += 9;
      x.b += 19;
    }
  }
  if (x.a != 56 || x.b != 86)
    __builtin_abort ();
}

int
main ()
{
  struct S x = { 42, 52 };
  #pragma omp parallel master
  foo (x);
  return 0;
}

is miscompiled, merge is called with the same argument twice instead of merging
from the task privatized variable(s) into the PARM_DECL.

             reply	other threads:[~2021-06-22 17:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 17:41 jakub at gcc dot gnu.org [this message]
2021-06-22 17:41 ` [Bug middle-end/101167] " jakub at gcc dot gnu.org
2021-06-23  8:06 ` cvs-commit at gcc dot gnu.org
2021-06-23 13:19 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:19 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:20 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub at gcc dot gnu.org

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=bug-101167-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: 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).