public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100301] New: sum of __int128 - regression since 8.2
@ 2021-04-28 1:45 dushistov at mail dot ru
2021-04-28 4:58 ` [Bug target/100301] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: dushistov at mail dot ru @ 2021-04-28 1:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100301
Bug ID: 100301
Summary: sum of __int128 - regression since 8.2
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dushistov at mail dot ru
Target Milestone: ---
For such simple function:
__int128 add1(__int128 a, __int128 b) {
return a + b;
}
gcc 8.2 generates for a + b:
mov r9, rdi
mov r10, rsi
add r9, rdx
adc r10, rcx
mov rax, r9
mov rdx, r10
ret
and for b + a:
add1(__int128, __int128):
mov rax, rdx
mov rdx, rcx
add rax, rdi
adc rdx, rsi
ret
but gcc 11.1 generates for both cases:
add1(__int128, __int128):
mov r9, rdi
mov rax, rdx
mov r8, rsi
mov rdx, rcx
add rax, r9
adc rdx, r8
ret
4 moves instead of 2.
Recent versions of clang and icc generates the same number and type of
instruction of both cases,
and only 2 moves and 2 additions:
icc:
add1(__int128, __int128):
add rdi, rdx
mov rax, rdi
adc rsi, rcx
mov rdx, rsi
ret
add1(__int128, __int128):
add rdx, rdi
mov rax, rdx
adc rcx, rsi
mov rdx, rcx
ret
clang:
add1(__int128, __int128):
mov rax, rdi
add rax, rdx
adc rsi, rcx
mov rdx, rsi
ret
add1(__int128, __int128):
mov rax, rdi
add rax, rdx
adc rsi, rcx
mov rdx, rsi
ret
Not sure is this target specific issue,
I get this example from this article: https://habr.com/ru/post/554760/ ,
where risc-v gcc 8.2.0 has similar problem that "a + b" and "b + a" uses
different number of instructions.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug target/100301] sum of __int128 - regression since 8.2
2021-04-28 1:45 [Bug c/100301] New: sum of __int128 - regression since 8.2 dushistov at mail dot ru
@ 2021-04-28 4:58 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-04-28 4:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100301
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC has always had issues with double register integer types and sometimes the
register allocator choses worse and sometimes better.
*** This bug has been marked as a duplicate of bug 97756 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-28 4:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 1:45 [Bug c/100301] New: sum of __int128 - regression since 8.2 dushistov at mail dot ru
2021-04-28 4:58 ` [Bug target/100301] " 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).