public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/115973] New: PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll
@ 2024-07-17 20:13 jens.seifert at de dot ibm.com
2024-07-17 21:16 ` [Bug target/115973] " jakub at gcc dot gnu.org
2024-09-07 12:17 ` jens.seifert at de dot ibm.com
0 siblings, 2 replies; 3+ messages in thread
From: jens.seifert at de dot ibm.com @ 2024-07-17 20:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115973
Bug ID: 115973
Summary: PPCLE: Inefficient code for __builtin_uaddll_overflow
and __builtin_addcll
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jens.seifert at de dot ibm.com
Target Milestone: ---
unsigned long long add(unsigned long long a, unsigned long long b, unsigned
long long *ovf)
{
return __builtin_addcll(a,b,0,ovf);
}
creates
mr 9,3
add 3,3,4
subfc 9,9,3
subfe 9,9,9
neg 9,9
std 9,0(5)
blr
Expected to addc + addze
unsigned long long add4(unsigned long long a, unsigned long long b, unsigned
long long *ovf)
{
unsigned long long t, res;
__asm__("li %0, 0; addc %1,%2,%3; addze
%0,%0":"=&r"(res),"=r"(t):"r"(a),"r"(b):"xer");
*ovf = res;
return t;
}
Expected assembly
li 9, 0
addc 3,3,4
addze 9,9
std 9,0(5)
blr
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/115973] PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll
2024-07-17 20:13 [Bug target/115973] New: PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll jens.seifert at de dot ibm.com
@ 2024-07-17 21:16 ` jakub at gcc dot gnu.org
2024-09-07 12:17 ` jens.seifert at de dot ibm.com
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-07-17 21:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115973
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
See PR43892
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/115973] PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll
2024-07-17 20:13 [Bug target/115973] New: PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll jens.seifert at de dot ibm.com
2024-07-17 21:16 ` [Bug target/115973] " jakub at gcc dot gnu.org
@ 2024-09-07 12:17 ` jens.seifert at de dot ibm.com
1 sibling, 0 replies; 3+ messages in thread
From: jens.seifert at de dot ibm.com @ 2024-09-07 12:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115973
--- Comment #2 from Jens Seifert <jens.seifert at de dot ibm.com> ---
Assembly that better integrates:
unsigned long long addc_opt(unsigned long long a, unsigned long long b,
unsigned long long *res)
{
unsigned long long rc;
__asm__("addc %0,%2,%3;\n\tsubfe
%1,%1,%1":"=r"(*res),"=r"(rc):"r"(a),"r"(b):"xer");
return rc + 1;
}
Output:
.L.addc_opt(unsigned long long, unsigned long long, unsigned long long*):
addc 9,3,4;
subfe 3,3,3
std 9,0(5)
addi 3,3,1
blr
Power10 code for __builtin_uaddll_overflow is okay:
unsigned long long addc(unsigned long long a, unsigned long long b, unsigned
long long *res)
{
return __builtin_uaddll_overflow(a, b, res);
}
.L.addc(unsigned long long, unsigned long long, unsigned long long*):
add 4,3,4
cmpld 0,4,3
std 4,0(5)
setbc 3,0
blr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-07 12:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-17 20:13 [Bug target/115973] New: PPCLE: Inefficient code for __builtin_uaddll_overflow and __builtin_addcll jens.seifert at de dot ibm.com
2024-07-17 21:16 ` [Bug target/115973] " jakub at gcc dot gnu.org
2024-09-07 12:17 ` jens.seifert at de dot ibm.com
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).