public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Christophe Lyon <christophe.lyon@arm.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 09/10] libgcc: Add support for HF mode (aka __fp16) in libbid
Date: Mon, 9 May 2022 21:27:56 +0000	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2205092119190.1058846@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20220509143507.239804-10-christophe.lyon@arm.com>

On Mon, 9 May 2022, Christophe Lyon via Gcc-patches wrote:

> This patch adds support for trunc and extend operations between HF
> mode (__fp16) and Decimal Floating Point formats (_Decimal32,
> _Decimal64 and _Decimal128).
> 
> For simplicity we rely on the implicit conversions inserted by the
> compiler between HF and SD/DF/TF modes.  The existing bid*_to_binary*
> and binary*_to_bid* functions are non-trivial and at this stage it is
> not clear if there is a performance-critical use case involving __fp16
> and _Decimal* formats.

Note that for conversion from DFP to HFmode, double rounding (going via 
SFmode) probably produces incorrectly rounded results in some cases 
(though we already have such incorrect results in the other direction for 
DPD; see bug 97635).

> The patch also adds two executable tests for AArch64, to make sure the
> right functions are used, available (link phase) and functional.

Wouldn't it be better to have tests that apply for all targets supporting 
both HFmode and BID DFP, which includes x86 / x86_64 (with SSE2 support) 
as well, using _Float16 as the type name (and the float16 / 
float16_runtime effective-target keywords to test for the relevant support 
and dg-add-options float16)?

> +HFtype
> +__bid_truncddhf (_Decimal64 x) {
> +  HFtype res;
> +  union decimal64 ux;
> +
> +  ux.d = x;
> +  res = __bid64_to_binary32 (ux.i);
> +  return (res);
> +}

Doesn't this need appropriate LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE 
conditionals like some of the other functions you're adding?

> +HFtype
> +__bid_truncsdhf (_Decimal32 x) {
> +  HFtype res;
> +  union decimal32 ux;
> +
> +  ux.d = x;
> +  res = __bid32_to_binary32 (ux.i);
> +  return (res);
> +}

Likewise.

> +HFtype
> +__bid_trunctdhf (_Decimal128 x) {
> +  HFtype res;
> +  union decimal128 ux;
> +
> +  ux.d = x;
> +  res = __bid128_to_binary32 (ux.i);
> +  return (res);
> +}

Likewise.

> +#if LIBGCC2_HAS_HF_MODE
> +typedef float HFtype __attribute__ ((mode (HF)));
> +#endif /* LIBGCC2_HAS_HF_MODE */
>  typedef float SFtype __attribute__ ((mode (SF)));
>  typedef float DFtype __attribute__ ((mode (DF)));
>  #if LIBGCC2_HAS_XF_MODE
> @@ -98,6 +111,12 @@ typedef __attribute__ ((aligned(16))) struct
>  #endif
>  #endif
>  
> +#if BID_HAS_HF_MODE
> +#ifndef HFtype
> +#define HFtype __fp16
> +#endif

That seems wrong; the __fp16 name is specific to Arm / AArch64.  I'd 
expect the typedef alone to be specific; in any case, the "mode" attribute 
is the appropriate way to define this type.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2022-05-09 21:28 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 14:34 [PATCH 00/10] Enable Decimal Floating Point (DFP) on AArch64 Christophe Lyon
2022-05-09 14:34 ` [PATCH 01/10] aarch64: Enable DFP (Decimal Floating-point) (BID format) Christophe Lyon
2022-05-09 14:34 ` [PATCH 02/10] aarch64: Add backend support for DFP Christophe Lyon
2022-05-10  9:23   ` Richard Sandiford
2022-05-10  9:30     ` Richard Sandiford
2022-05-10 10:18       ` Christophe Lyon
2022-05-13 16:08   ` [PATCH v2 " Christophe Lyon
2022-05-13 16:35     ` Richard Sandiford
2022-05-16 12:17       ` Christophe Lyon
2022-05-09 14:35 ` [PATCH 03/10] libgcc: Enable XF mode conversions to/from DFP modes only if supported Christophe Lyon
2022-05-09 14:35 ` [PATCH 04/10] libgcc: enable DFP for AArch64 Christophe Lyon
2022-05-09 14:35 ` [PATCH 05/10] testsuite:: Fix pr39986.c testcase " Christophe Lyon
2022-05-09 14:35 ` [PATCH 06/10] testsuite: Add new tests for DFP under aarch64/aapcs64 Christophe Lyon
2022-05-09 14:35 ` [PATCH 07/10] testsuite: enable more BID DFP tests for AArch64 Christophe Lyon
2022-05-09 14:35 ` [PATCH 08/10] testsuite: Add C++ unwinding tests with Decimal Floating-Point Christophe Lyon
2022-05-10  9:27   ` Richard Sandiford
2022-05-13 16:35   ` [PATCH v2 " Christophe Lyon
2022-05-13 17:52   ` Christophe Lyon
2022-05-16 10:33     ` Richard Sandiford
2022-05-09 14:35 ` [PATCH 09/10] libgcc: Add support for HF mode (aka __fp16) in libbid Christophe Lyon
2022-05-09 21:27   ` Joseph Myers [this message]
2022-05-10  8:08     ` Christophe Lyon
2022-05-10 20:26       ` Joseph Myers
2022-05-13 16:34   ` [PATCH v2 " Christophe Lyon
2022-05-13 17:52   ` Christophe Lyon
2022-05-13 18:23     ` Joseph Myers
2022-05-13 18:30       ` Christophe Lyon
2022-05-16 13:47       ` [PATCH v3 09/10] libgcc: Add support for HF mode (aka _Float16) " Christophe Lyon
2022-05-19 13:03         ` Christophe Lyon
2022-05-19 19:35           ` Joseph Myers
2022-05-20  7:47             ` Christophe Lyon
2022-05-09 14:35 ` [PATCH 10/10] libgcc: use __builtin_clz and __builtin_ctz " Christophe Lyon
2022-05-10  9:37 ` [PATCH 00/10] Enable Decimal Floating Point (DFP) on AArch64 Richard Sandiford

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=alpine.DEB.2.22.394.2205092119190.1058846@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=christophe.lyon@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).