public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64
@ 2021-11-21 13:20 jacob at jacob dot remcomp.fr
2021-11-21 13:25 ` [Bug c/103348] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jacob at jacob dot remcomp.fr @ 2021-11-21 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
Bug ID: 103348
Summary: Bad code generated for fabs(long double) under aarch64
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jacob at jacob dot remcomp.fr
Target Milestone: ---
Machine aarch64 linux
when compiling:
long double ld;
ld = fabs(ld);
The compiler generates:
ldr q0, [x29, 16]
bl __trunctfdf2
fabs d0, d0
bl __extenddftf2
str q0, [x29, 16]
You truncate de 128 bit long double to 64, then extend it to 128 bits! You
loose ALL PRECISION!
Incredible
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103348] Bad code generated for fabs(long double) under aarch64
2021-11-21 13:20 [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64 jacob at jacob dot remcomp.fr
@ 2021-11-21 13:25 ` pinskia at gcc dot gnu.org
2021-11-21 14:45 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-21 13:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
Last reconfirmed| |2021-11-21
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Full testcase?
Is this c or c++?
Also if this is c, you should be using fabsl for long double.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103348] Bad code generated for fabs(long double) under aarch64
2021-11-21 13:20 [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64 jacob at jacob dot remcomp.fr
2021-11-21 13:25 ` [Bug c/103348] " pinskia at gcc dot gnu.org
@ 2021-11-21 14:45 ` pinskia at gcc dot gnu.org
2021-11-21 14:57 ` jacob at jacob dot remcomp.fr
2021-11-21 15:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-21 14:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#include <math.h>
long double
f(long double ld)
{
ld = fabsl(ld);
return ld;
};
Works correctly.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103348] Bad code generated for fabs(long double) under aarch64
2021-11-21 13:20 [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64 jacob at jacob dot remcomp.fr
2021-11-21 13:25 ` [Bug c/103348] " pinskia at gcc dot gnu.org
2021-11-21 14:45 ` pinskia at gcc dot gnu.org
@ 2021-11-21 14:57 ` jacob at jacob dot remcomp.fr
2021-11-21 15:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jacob at jacob dot remcomp.fr @ 2021-11-21 14:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
--- Comment #3 from jacob navia <jacob at jacob dot remcomp.fr> ---
1) The complete program is as follows:
#include <math.h>
int main(void)
{
long double ld = -2.3L;
ld = fabs(ld);
}
Compiler flags
gcc -S -c -std=c99 tafbs1.c
As per standard c99 fabs is a generic function.
After your remark, gcc generates correct code when I explicitly include
<tgmath.h>
This is surprising
> Le 21 nov. 2021 à 14:25, pinskia at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> a écrit :
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
>
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|UNCONFIRMED |WAITING
> Ever confirmed|0 |1
> Last reconfirmed| |2021-11-21
>
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Full testcase?
> Is this c or c++?
> Also if this is c, you should be using fabsl for long double.
>
> --
> You are receiving this mail because:
> You reported the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103348] Bad code generated for fabs(long double) under aarch64
2021-11-21 13:20 [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64 jacob at jacob dot remcomp.fr
` (2 preceding siblings ...)
2021-11-21 14:57 ` jacob at jacob dot remcomp.fr
@ 2021-11-21 15:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-21 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103348
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to jacob navia from comment #3)
> As per standard c99 fabs is a generic function.
NO, you need to include tgmath.h for generic math functions.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-21 15:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-21 13:20 [Bug c/103348] New: Bad code generated for fabs(long double) under aarch64 jacob at jacob dot remcomp.fr
2021-11-21 13:25 ` [Bug c/103348] " pinskia at gcc dot gnu.org
2021-11-21 14:45 ` pinskia at gcc dot gnu.org
2021-11-21 14:57 ` jacob at jacob dot remcomp.fr
2021-11-21 15:00 ` 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).