public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "patrick at rivosinc dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/114202] New: [14] RISC-V rv64gcv: miscompile at -O3
Date: Sat, 02 Mar 2024 02:10:49 +0000	[thread overview]
Message-ID: <bug-114202-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114202
           Summary: [14] RISC-V rv64gcv: miscompile at -O3
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Testcase:
int printf(const char *, ...);
signed char a, d;
_Bool b;
signed char c[324];
int e;
int main() {
  c[63] = 50;
  for (int f = 0; f < 9; f++) {
    for (unsigned g = 0; g < 12; g++)
      for (char h = 0; h < 8; h++)
        e = a += c[g * 9];
    b = e ? d : 0;
  }
  printf("%d\n", a);
}

Commands:
> /scratch/tc-testing/tc-feb-20/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O3 -fwrapv red.c -o red.out
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/qemu-riscv64 red.out
32
> /scratch/tc-testing/tc-feb-20/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O2 -fwrapv red.c -o red.out
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/qemu-riscv64 red.out
16

With the overflows (-fwrapv) the expected value is 16.

Tested/found using r14-9084-g61ab046a327 (not bisected)

Found via fuzzer.

             reply	other threads:[~2024-03-02  2:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02  2:10 patrick at rivosinc dot com [this message]
2024-03-02  2:13 ` [Bug target/114202] " patrick at rivosinc dot com
2024-03-06 19:42 ` cvs-commit at gcc dot gnu.org
2024-03-06 19:43 ` rdapp 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-114202-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).