public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ckk at kvr dot at" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/104353] New: ppc64le: Apparent reliance on undefined behavior of xvcvdpsxws Date: Wed, 02 Feb 2022 19:30:28 +0000 [thread overview] Message-ID: <bug-104353-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104353 Bug ID: 104353 Summary: ppc64le: Apparent reliance on undefined behavior of xvcvdpsxws Product: gcc Version: 11.2.0 URL: https://github.com/numpy/numpy/issues/20964#issuecomme nt-1027865665 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ckk at kvr dot at Target Milestone: --- Created attachment 52331 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52331&action=edit Minimal test case for reproduction I ran into a strange numpy error on ppc64le that only occurred inside a ppc64le QEMU instance. In short, casting arrays of i doubles 1.0 to ints 1 worked as expected on native hardware, but produced the following bogus results when running inside a VM: i = 1: 1 i = 2: 1 1 i = 3: 1 1 1 i = 4: 0 0 0 0 i = 5: 0 0 0 0 1 i = 6: 0 0 0 0 1 1 i = 7: 0 0 0 0 1 1 1 i = 8: 0 0 0 0 0 0 0 0 i = 9: 0 0 0 0 0 0 0 0 1 ... Guided by the numpy folks, a SIMD issue was suspected, and I managed to create a minimal test case (attached here) with which this could be reproduced. It only occurs with -O3. I then filed an issue with QEMU, where the issue was quickly rejected. This led to further analysis by the numpy folks. There, it was discovered that GCC is apparently relying on undefined behavior of the xvcvdpsxws instruction, which happened to work on native hardware because it happen to exhibit that behavior. I'm only summarizing here; there's a great analysis in detail, and a much better test case, on the GitHub issue, which I have linked in the URL as I'd prefer not to reproduce the author's work here.
next reply other threads:[~2022-02-02 19:30 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-02 19:30 ckk at kvr dot at [this message] 2022-02-16 15:48 ` [Bug target/104353] " segher at gcc dot gnu.org 2022-02-16 19:55 ` ckk at kvr dot at 2022-02-18 8:43 ` seiko at imavr dot com
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-104353-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: 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).