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