public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xry111 at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/111403] New: LoongArch: Wrong code with -O -mlasx -fopenmp-simd
Date: Wed, 13 Sep 2023 10:46:05 +0000	[thread overview]
Message-ID: <bug-111403-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111403
           Summary: LoongArch: Wrong code with -O -mlasx -fopenmp-simd
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

Testcase:

struct S
{
  int s;
  S () : s (0) {}
  ~S () {}
  S (const S &x) { s = x.s; }
  S &
  operator= (const S &x)
  {
    s = x.s;
    return *this;
  }
};

S r, a[1024], b[1024];

#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s)

__attribute__ ((noipa)) void
foo (S *a, S *b)
{
#pragma omp simd reduction(inscan, + : r)
  for (int i = 0; i < 1024; i++)
    {
      r.s += a[i].s;
#pragma omp scan inclusive(r)
      b[i] = r;
    }
}

int
main ()
{
  S s;
  for (int i = 0; i < 1024; ++i)
    {
      a[i].s = i;
      b[i].s = -1;
    }
  foo (a, b);
  if (r.s != 1024 * 1023 / 2)
    __builtin_abort ();
  return 0;
}

$ g++ t.cc -O -mlasx -fopenmp-simd
$ ./a.out
Aborted (core dumped)

             reply	other threads:[~2023-09-13 10:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13 10:46 xry111 at gcc dot gnu.org [this message]
2023-09-13 10:48 ` [Bug target/111403] " xry111 at gcc dot gnu.org
2023-10-08  8:45 ` guojie at loongson dot cn
2024-01-31 10:44 ` xry111 at gcc dot gnu.org
2024-01-31 16:45 ` xry111 at gcc dot gnu.org
2024-01-31 16:48 ` xry111 at gcc dot gnu.org
2024-01-31 17:17 ` schwab@linux-m68k.org
2024-01-31 17:23 ` xry111 at gcc dot gnu.org
2024-02-01  6:17 ` panchenghui at loongson dot cn

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-111403-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).