public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "chfast at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106786] New: Regression in cmp+sbb Date: Wed, 31 Aug 2022 11:16:48 +0000 [thread overview] Message-ID: <bug-106786-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106786 Bug ID: 106786 Summary: Regression in cmp+sbb Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chfast at gmail dot com Target Milestone: --- I noticed a regression when using the builtin for sbb instruction (__builtin_ia32_sbb_u64). typedef unsigned long long u64; struct R { u64 value; bool carry; }; inline R subc(u64 x, u64 y, bool carry) noexcept { u64 d; const u64 carryout = __builtin_ia32_sbb_u64(carry, x, y, &d); return {d, carryout != 0}; } bool bad(u64 x, u64 y) { const R z = subc(x, y, false); R a = subc(x, y, z.carry); return a.carry; } https://godbolt.org/z/f41KKe19q The expected assembly is cmp rdi, rsi sbb rdi, rsi But GCC 12.2.0 and trunk produces cmp rdi, rsi setb al movzx eax, al add al, -1 sbb rdi, rsi The regression is in 12.2.0, the 11.3.0 optimizes properly. There are simple changes which will bring back the expected optimization: - change `const R z` to `R z`, - change `bool carry` to `u64 carry`. This may be related to calling convention / ABI because I noticed in one of the tree optimization outputs for 12.2.0 that the `bool carry` is forced to be in memory: `MEM <unsigned char> [(struct R *)&z + 8B]`. https://godbolt.org/z/7zh7GxraK
next reply other threads:[~2022-08-31 11:16 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-31 11:16 chfast at gmail dot com [this message] 2022-08-31 15:56 ` [Bug tree-optimization/106786] " pinskia at gcc dot gnu.org 2022-08-31 16:03 ` [Bug tree-optimization/106786] [12/13 Regression] " pinskia at gcc dot gnu.org 2022-10-19 6:52 ` [Bug tree-optimization/106786] [12/13 Regression] SRA regression causes extra instructions sometimes rguenth at gcc dot gnu.org 2022-11-29 12:38 ` chfast at gmail dot com 2022-12-27 14:32 ` [Bug tree-optimization/106786] [12/13 Regression] SRA regression causes extra instructions sometimes since r12-1529-gd7deee423f993bee marxin at gcc dot gnu.org 2023-05-08 12:25 ` [Bug tree-optimization/106786] [12/13/14 " 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-106786-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).