public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/94804] New: Failure to elide useless movs in 128-bit addition
@ 2020-04-27 16:42 gabravier at gmail dot com
  2020-04-27 20:50 ` [Bug rtl-optimization/94804] " gabravier at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-04-27 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94804
           Summary: Failure to elide useless movs in 128-bit addition
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

using i128 = __int128;

i128 add128(i128 a, i128 b)
{
    return a + b;
}

This is how LLVM handles this code : 

add128(__int128, __int128):
  mov rax, rdi
  add rax, rdx
  adc rsi, rcx
  mov rdx, rsi
  ret

GCC seems to have an insistence on moving `b` from its original registers
before actually doing the addition : 

add128(__int128, __int128):
  mov r9, rdi ; useless
  mov rax, rdx
  mov r8, rsi ; useless
  mov rdx, rcx
  add rax, r9 ; could just have used rdi
  adc rdx, r8 ; could just have used rsi
  ret

This seems to be specific to x86_64 : It does not occur on aarch64 or ppc64le

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-01-19 23:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 16:42 [Bug rtl-optimization/94804] New: Failure to elide useless movs in 128-bit addition gabravier at gmail dot com
2020-04-27 20:50 ` [Bug rtl-optimization/94804] " gabravier at gmail dot com
2020-04-28  6:49 ` glisse at gcc dot gnu.org
2020-04-28  7:41 ` rguenth at gcc dot gnu.org
2020-04-28 12:38 ` gabravier at gmail dot com
2020-04-28 17:14 ` glisse at gcc dot gnu.org
2023-01-19 23:17 ` pinskia at gcc dot gnu.org
2023-01-19 23:20 ` [Bug rtl-optimization/94804] Failure to elide useless movs in 128-bit addition with __int128_t arguments pinskia at gcc dot gnu.org
2023-01-19 23:23 ` pinskia at gcc dot gnu.org

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).