Gentle ping! :)
Kind regards,
Torbjörn
On 2026-11-09 07:32, Torbjörn Svensson via Sourceware Forge wrote:
From: Torbjörn SVENSSON <[email protected]>
Arm currently does not build __mulhc3 and __divhc3 because the default
libgcc floating-mode hook does not support HFmode.
Add an Arm hook to enable HFmode support when the IEEE fp16 format is
selected, and compile these helpers with -mfp16-format=ieee.
PR target/124053
gcc/ChangeLog:
* config/arm/arm.cc (arm_libgcc_floating_mode_supported_p): New.
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
libgcc/ChangeLog:
* config/arm/t-softfp: Add $(softfp_cflags) to INTERNAL_CFLAGS
for _mulhc3 and _divhc3.
Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
This patch adds the missing __mulhc3 and __divhc3 helpers to Arm's libgcc by
enabling HFmode support for the IEEE fp16 format and building the helpers with
-mfp16-format=ieee.
It fixes the link failures in these tests on arm-none-eabi (armv8.1-m.main):
- FAIL: gcc.dg/c23-imaginary-constants-7.c (test for excess errors)
- UNRESOLVED: gcc.dg/c23-imaginary-constants-7.c compilation failed to produce
executable
- FAIL: gcc.dg/c2y-imaginary-constants-7.c (test for excess errors)
- UNRESOLVED: gcc.dg/c2y-imaginary-constants-7.c compilation failed to produce
executable
- FAIL: gcc.dg/torture/float16-complex.c -O0 (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O0 compilation failed to
produce executable
- FAIL: gcc.dg/torture/float16-complex.c -O1 (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O1 compilation failed to
produce executable
- FAIL: gcc.dg/torture/float16-complex.c -O2 (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O2 compilation failed to
produce executable
- FAIL: gcc.dg/torture/float16-complex.c -O3 -g (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O3 -g compilation failed to
produce executable
- FAIL: gcc.dg/torture/float16-complex.c -Os (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -Os compilation failed to
produce executable
- FAIL: gcc.dg/torture/float16-complex.c -O2 -flto -fno-use-linker-plugin
-flto-partition=none (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O2 -flto
-fno-use-linker-plugin -flto-partition=none compilation failed to produce
executable
- FAIL: gcc.dg/torture/float16-complex.c -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects (test for excess errors)
- UNRESOLVED: gcc.dg/torture/float16-complex.c -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects compilation failed to produce executable
Regtested on arm-none-eabi, using r17-5743-ge33129b871c302 as baseline.
Ok for trunk and releases/gcc-16?
--
This is a forge pull request published on the gcc-patches mailing list mailing
list
as requested by Torbjörn Svensson via Sourceware Forge
<[email protected]>.
Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/269
Get it locally using:
```
git fetch forge-upstream "+refs/versioned_pull/269/*:refs/versioned_pull/269/*"
git switch -c "pr-269-v1" "refs/versioned_pull/269/1/head"
```
Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/269.diff
Created on: 2026-11-09 06:20:10+00:00
Latest update: 2026-11-09 06:32:24+00:00
Changes: 2 changed files, 23 additions, 0 deletions
Head revision: azoff/gcc ref pr/mulhc3_divhc3 commit
dafc37519893cb322c2fed2e600877fd5efce318
Base revision: gcc/gcc ref trunk commit
e33129b871c30276acfaed2b435ae5b505b73655 r17-5743-ge33129b871c302
Merge base: e33129b871c30276acfaed2b435ae5b505b73655
Requested Reviewers:
Changed files:
- M: gcc/config/arm/arm.cc
- M: libgcc/config/arm/t-softfp
gcc/config/arm/arm.cc | 19 +++++++++++++++++++
libgcc/config/arm/t-softfp | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 940c689b21e0e..2d93ca5c741df 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -253,6 +253,7 @@ static bool arm_allocate_stack_slots_for_args (void);
static bool arm_warn_func_return (tree);
static tree arm_promoted_type (const_tree t);
static bool arm_scalar_mode_supported_p (scalar_mode);
+static bool arm_libgcc_floating_mode_supported_p (scalar_float_mode);
static bool arm_frame_pointer_required (void);
static bool arm_can_eliminate (const int, const int);
static void arm_asm_trampoline_template (FILE *);
@@ -709,6 +710,10 @@ static const scoped_attribute_specs *const
arm_attribute_table[] =
#undef TARGET_SCALAR_MODE_SUPPORTED_P
#define TARGET_SCALAR_MODE_SUPPORTED_P arm_scalar_mode_supported_p
+#undef TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P
+#define TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P \
+ arm_libgcc_floating_mode_supported_p
+
#undef TARGET_COMPUTE_FRAME_LAYOUT
#define TARGET_COMPUTE_FRAME_LAYOUT arm_compute_frame_layout
@@ -25069,6 +25074,20 @@ arm_scalar_mode_supported_p (scalar_mode mode)
return default_scalar_mode_supported_p (mode);
}
+/* Implement TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P. HFmode is only
+ supported with the IEEE fp16 format, as that is the format libgcc's
+ HFmode routines are built with. Other modes are handled by the
+ default implementation. */
+
+static bool
+arm_libgcc_floating_mode_supported_p (scalar_float_mode mode)
+{
+ if (mode == HFmode)
+ return (arm_fp16_format == ARM_FP16_FORMAT_IEEE);
+ else
+ return default_libgcc_floating_mode_supported_p (mode);
+}
+
/* Set the value of FLT_EVAL_METHOD.
ISO/IEC TS 18661-3 defines two values that we'd like to make use of:
diff --git a/libgcc/config/arm/t-softfp b/libgcc/config/arm/t-softfp
index ab3bbbd2fd05b..fe00b5d52ee14 100644
--- a/libgcc/config/arm/t-softfp
+++ b/libgcc/config/arm/t-softfp
@@ -3,3 +3,7 @@ softfp_wrap_end := '\#endif'
bitint_extras += floatbitinthf
softfp_cflags := -mfp16-format=ieee
LIB2ADD += $(srcdir)/config/arm/sfp-exceptions.c
+
+# __mulhc3 and __divhc3 from libgcc2.c need HFmode, which requires an
+# fp16 format to be selected.
+_mulhc3$(objext) _divhc3$(objext): INTERNAL_CFLAGS += $(softfp_cflags)