public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] i386: Fix up types in __builtin_{inf,huge_val,nan{,s},fabs,copysign}q builtins [PR109884]
Date: Wed, 17 May 2023 20:30:28 +0200	[thread overview]
Message-ID: <CAFULd4aFrhjLP=KAMZWCRUd2HzRmQnGKYGnV7-duvUh1NM7JDA@mail.gmail.com> (raw)
In-Reply-To: <ZGUYH+SgUWanqPVA@tucnak>

On Wed, May 17, 2023 at 8:08 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> When _Float128 support has been added to C++ for 13.1,  float128t_type_node
> tree has been added - in C float128_type_node and float128t_type_node is
> the same and represents both _Float128 and __float128, but in C++ they
> are distinct types which have different handling in the FEs.
> When doing that change, I mistakenly forgot to change FLOAT128 primitive
> type, which is used for the __builtin_{inf,huge_val,nan{,s},fabs,copysign}q
> builtins results and some of their arguments (and nothing else).
>
> The following patch fixes that.
> On ia64 we already use float128t_type_node for those builtins, pa while
> it has __float128 that type is the same as long double and so those builtins
> have long double types and on powerpc seems we  don't have these builtins
> but instead define macros which map them to __builtin_*f128.  That will
> not work properly in C++, perhaps we should change those macros to be
> function-like and cast to __float128.
>
> Anyway, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk
> and 13.2?
>
> 2023-05-17  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/109884
>         * config/i386/i386-builtin-types.def (FLOAT128): Use
>         float128t_type_node rather than float128_type_node.
>
>         * c-c++-common/pr109884.c: New test.

OK for master and branch.

Thanks,
Uros.

>
> --- gcc/config/i386/i386-builtin-types.def.jj   2022-11-28 22:25:15.838734978 +0100
> +++ gcc/config/i386/i386-builtin-types.def      2023-05-17 10:24:04.297929428 +0200
> @@ -73,7 +73,7 @@ DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_
>  DEF_PRIMITIVE_TYPE (FLOAT, float_type_node)
>  DEF_PRIMITIVE_TYPE (DOUBLE, double_type_node)
>  DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node)
> -DEF_PRIMITIVE_TYPE (FLOAT128, float128_type_node)
> +DEF_PRIMITIVE_TYPE (FLOAT128, float128t_type_node)
>  DEF_PRIMITIVE_TYPE (CONST_STRING, const_string_type_node)
>
>  # MMX vectors
> --- gcc/testsuite/c-c++-common/pr109884.c.jj    2023-05-17 10:41:42.295838862 +0200
> +++ gcc/testsuite/c-c++-common/pr109884.c       2023-05-17 10:56:51.731872318 +0200
> @@ -0,0 +1,32 @@
> +/* PR c++/109884 */
> +/* PowerPC doesn't define these as builtins, but macros expanding to
> +   *f128 builtins.  */
> +/* { dg-do compile { target { __float128 && { { c || c++11 } && { ! powerpc*-*-* } } } } } */
> +/* { dg-add-options __float128 } */
> +
> +#ifdef __cplusplus
> +template <typename T, typename U>
> +struct is_same {
> +  static const bool value = false;
> +};
> +
> +template <typename T>
> +struct is_same <T, T> {
> +  static const bool value = true;
> +};
> +#define HAS_TYPE(E, U) static_assert (is_same <decltype (E), U>::value, "")
> +#else
> +#define HAS_TYPE(E, U) _Static_assert (_Generic (E, default : 0, U : 1), "")
> +#endif
> +
> +void
> +foo ()
> +{
> +  __float128 a = 0;
> +  HAS_TYPE (__builtin_infq (), __float128);
> +  HAS_TYPE (__builtin_huge_valq (), __float128);
> +  HAS_TYPE (__builtin_nanq (""), __float128);
> +  HAS_TYPE (__builtin_nansq (""), __float128);
> +  HAS_TYPE (__builtin_fabsq (a), __float128);
> +  HAS_TYPE (__builtin_copysignq (a, a), __float128);
> +}
>
>         Jakub
>

      reply	other threads:[~2023-05-17 18:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 18:08 Jakub Jelinek
2023-05-17 18:30 ` Uros Bizjak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFULd4aFrhjLP=KAMZWCRUd2HzRmQnGKYGnV7-duvUh1NM7JDA@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).