* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
@ 2023-08-18 7:24 ` pinskia at gcc dot gnu.org
2023-08-18 8:18 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-08-18
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fnan
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm
.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
2023-08-18 7:24 ` [Bug c/111058] __builtin_nans (and its friends for other floating-point types) " pinskia at gcc dot gnu.org
@ 2023-08-18 8:18 ` pinskia at gcc dot gnu.org
2023-08-18 8:34 ` chenxiaolong at loongson dot cn
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18 8:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Newer version of that paper:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1011.htm
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
2023-08-18 7:24 ` [Bug c/111058] __builtin_nans (and its friends for other floating-point types) " pinskia at gcc dot gnu.org
2023-08-18 8:18 ` pinskia at gcc dot gnu.org
@ 2023-08-18 8:34 ` chenxiaolong at loongson dot cn
2023-08-18 8:44 ` chenxiaolong at loongson dot cn
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiaolong at loongson dot cn @ 2023-08-18 8:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
chenxiaolong <chenxiaolong at loongson dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |chenxiaolong at loongson dot cn
--- Comment #3 from chenxiaolong <chenxiaolong at loongson dot cn> ---
//test.c
#include<stdio.h>
int main(void)
{
_Float128 ret=__builtin_nansf128("NAN");
printf("ret=%Lf\n",ret);
return 0;
}
Compile command: gcc test.c -s -o -
result:
x86_64:
...
movl $.LC0, %edi
call __builtin_nansf128
...
LoongArch:
la.local $r4,.LC0
bl %plt(__builtin_nansf128)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
` (2 preceding siblings ...)
2023-08-18 8:34 ` chenxiaolong at loongson dot cn
@ 2023-08-18 8:44 ` chenxiaolong at loongson dot cn
2023-08-18 13:29 ` joseph at codesourcery dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiaolong at loongson dot cn @ 2023-08-18 8:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
--- Comment #4 from chenxiaolong <chenxiaolong at loongson dot cn> ---
(In reply to chenxiaolong from comment #3)
> //test.c
> #include<stdio.h>
>
> int main(void)
> {
> _Float128 ret=__builtin_nansf128("NAN");
> printf("ret=%Lf\n",ret);
>
> return 0;
> }
> Compile command: gcc test.c -s -o -
> result:
>
> x86_64:
> ...
> movl $.LC0, %edi
> call __builtin_nansf128
> ...
> LoongArch:
>
> la.local $r4,.LC0
> bl %plt(__builtin_nansf128)
Compile command: gcc test.c -S -o -
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
` (3 preceding siblings ...)
2023-08-18 8:44 ` chenxiaolong at loongson dot cn
@ 2023-08-18 13:29 ` joseph at codesourcery dot com
2023-08-18 13:34 ` xry111 at gcc dot gnu.org
2023-08-18 18:19 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2023-08-18 13:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
We should absolutely *not* generate calls to a non-existent function
"nans" based on a long-obsolescent standard proposal. The modern way to
generate a signaling NaN with given payload, as specified in C23, is to
generate a signaling NaN with one of the *_SNAN macros (FLT128_SNAN in
this case) in <float.h>, then use the relevant setpayload function
(setpayloadf128 in this case) to set its payload.
I don't think there is any bug here at all.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
` (4 preceding siblings ...)
2023-08-18 13:29 ` joseph at codesourcery dot com
@ 2023-08-18 13:34 ` xry111 at gcc dot gnu.org
2023-08-18 18:19 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-08-18 13:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
--- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to joseph@codesourcery.com from comment #5)
> We should absolutely *not* generate calls to a non-existent function
> "nans" based on a long-obsolescent standard proposal. The modern way to
> generate a signaling NaN with given payload, as specified in C23, is to
> generate a signaling NaN with one of the *_SNAN macros (FLT128_SNAN in
> this case) in <float.h>, then use the relevant setpayload function
> (setpayloadf128 in this case) to set its payload.
>
> I don't think there is any bug here at all.
But generating an external call to __builtin_* just does not make sense at all.
If the payload won't be supported, we should just emit a diagnostic and reject
the code.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111058] __builtin_nans (and its friends for other floating-point types) compiles to an external call to __builtin_nans for unsupported tag
2023-08-18 7:18 [Bug c/111058] New: __builtin_nans (and its friends) compiles to an external call to __builtin_nans for unsupported tag xry111 at gcc dot gnu.org
` (5 preceding siblings ...)
2023-08-18 13:34 ` xry111 at gcc dot gnu.org
@ 2023-08-18 18:19 ` joseph at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2023-08-18 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111058
--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
There shouldn't be such a thing as an unsupported constant payload; both
__builtin_nan and __builtin_nans should rather be made consistent with
parsing of payloads by glibc's nan functions (that may in some cases mean
changing glibc; see https://sourceware.org/bugzilla/show_bug.cgi?id=28322
- glibc's functions don't handle payloads wider than 64 bits for
_Float128, but GCC's do).
^ permalink raw reply [flat|nested] 8+ messages in thread