public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rl.alt.accnt at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug other/108471] New: Suboptimal codegen for __int128 subtraction on x86_64 Date: Thu, 19 Jan 2023 21:48:16 +0000 [thread overview] Message-ID: <bug-108471-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108471 Bug ID: 108471 Summary: Suboptimal codegen for __int128 subtraction on x86_64 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: rl.alt.accnt at gmail dot com Target Milestone: --- On x86_64, GCC generates an excessive amount of redundant `mov` instructions for `__int128` subtraction in C/C++. Clicking through versions on godbolt shows that this started getting worse in GCC 9.1 and later versions. See also https://godbolt.org/z/86v6ar457 The code: ``` __int128 sub(__int128 a, __int128 b) { return a - b; } ``` At -O3 or -O2, GCC (trunk) generates: ``` sub: mov r8, rdi mov rax, rsi mov rsi, r8 mov rdi, rax mov r8, rdx mov rax, rsi mov rdx, rdi sub rax, r8 sbb rdx, rcx ret ``` Interestingly, the use of `r8` in the first three instructions disappears when compiling w/ -O1, and those instructions are folded into two `mov`s instead. By contrast, Clang (also at -O3) generates: ``` sub: mov rax, rdi sub rax, rdx sbb rsi, rcx mov rdx, rsi ret ``` This is probably not a high-priority bug; I just wanted to bring attention to the fact that this is happening.
next reply other threads:[~2023-01-19 21:48 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-19 21:48 rl.alt.accnt at gmail dot com [this message] 2023-01-19 22:02 ` [Bug rtl-optimization/108471] " pinskia at gcc dot gnu.org 2023-01-19 23:17 ` pinskia 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-108471-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).