public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "benjsith at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109973] New: Wrong code for AVX2 since 13.1 by combining VPAND and VPTEST Date: Fri, 26 May 2023 00:38:41 +0000 [thread overview] Message-ID: <bug-109973-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109973 Bug ID: 109973 Summary: Wrong code for AVX2 since 13.1 by combining VPAND and VPTEST Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: benjsith at gmail dot com Target Milestone: --- The following code is a minimal repro of the issue, when compiled with `gcc -O1 -mavx2`: #include <immintrin.h> int do_stuff(__m256i Y0, __m256i Y1, __m128i X2) { __m256i And01 = _mm256_and_si256(Y0, Y1); int TestResult = _mm256_testc_si256(And01, And01); return TestResult; } I have also attached the preprocessed version of that minimal repro 12.3 produces the following assembly vpand ymm0, ymm0, ymm1 ; <<<<< missing in 13.1 mov eax, 0 vptest ymm0, ymm0 setb al ret While 13.1 generates: mov eax, 0 vptest ymm0, ymm1 setb al ret Note that as of 13.1, the VPAND is removed, and just the VPTEST remains. However, this is incorrect because _mm256_testc_si256 returns the results of the Carry Flag, which is based on the bitwise AND of the second operand and the bitwise NOT of the first operand, meaning these two can't be combined like that for this intrinsic Here is a Godbolt link showing the issue with a full execution case: https://godbolt.org/z/x9or4WEWh This issue is present in 12.3 but not 13.1. A bisect shows that it was most likely introduced in a56c1641e9d25e46059168e811b4a2f185f07b6b I have confirmed that this issue is still present on the latest trunk, 8d2fa90a41567670d2dbd4918d19d21d9bec4a8f -O0 on trunk will also return the correct result For triage/priority purposes: this bug was not found in manually written code, but instead from a fuzzer meant to test SIMD codegen PS: This is my first bug on the GCC tracker, so if I've done anything wrong let me know. I marked it as in "rtl-optimization" though I'm not sure if that's correct
next reply other threads:[~2023-05-26 0:38 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-26 0:38 benjsith at gmail dot com [this message] 2023-05-26 0:42 ` [Bug rtl-optimization/109973] " benjsith at gmail dot com 2023-05-26 0:47 ` [Bug target/109973] [13/14 Regression] " pinskia at gcc dot gnu.org 2023-05-26 6:31 ` [Bug target/109973] [13/14 Regression] Wrong code for AVX2 since 13.1 by combining VPAND and VPTEST since r13-2006-ga56c1641e9d25e rguenth at gcc dot gnu.org 2023-05-26 6:56 ` jakub at gcc dot gnu.org 2023-05-26 12:06 ` benjsith at gmail dot com 2023-05-29 18:24 ` roger at nextmovesoftware dot com 2023-05-30 13:44 ` cvs-commit at gcc dot gnu.org 2023-06-01 14:12 ` cvs-commit at gcc dot gnu.org 2023-06-03 18:01 ` benjsith at gmail dot com 2023-06-04 11:01 ` cvs-commit at gcc dot gnu.org 2023-06-22 6:44 ` cvs-commit at gcc dot gnu.org 2023-07-03 13:28 ` [Bug target/109973] [13 " roger at nextmovesoftware dot com 2023-07-03 13:43 ` jakub at gcc dot gnu.org 2023-07-20 7:28 ` rguenth 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-109973-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).