large overhead when cast float to uint64_t for arm cortex-m4 (ARMv7E-M fpv4-sp-d16). Compiler: arm-none-eabi-gcc

Bug #2075356 reported by Sergei
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Sergei
Newlib
New
Undecided
Sergei

Bug Description

To cast float to uint64 the initial value first converted to double. Cortex-M4 does not have hardware support for "double". Therefore, such an implementation adds several kilobytes of code, which is unacceptable for embeded systems with limited resources. In addition, increasing the code size is, of course, low performance.
I think there is a need to separate softfloat functions for platforms that only have hardware float support. The current version cannot be used for embedded systems. Additional functions need to be written.
Below is the __aeabi_f2ulz code for fpv4-sp-d16 (ieee 754):

uint64_t __aeabi_f2ulz(float f)
{
  uint32_t result = *((uint32_t*)&f);
  uint32_t exp;
  result &= (~0x80000000);
  exp = result >> 23;
  result |= 0x800000;
  if (exp < 0x7F)
  {
    return 0;
  }
  if (exp <= 0x96U)
  {
      exp = 0x96 - exp;
      result >>= exp;
      return (uint64_t)result;
  }
  exp -=0x96U;
  return (uint64_t)result << exp;
}

bin>arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=C:/work/distributiv/arm-gnu-toolchain-13.2/bin/../libexec/gcc/arm-none-eabi/13.2.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /data/jenkins/workspace/GNU-toolchain/arm-13/src/gcc/configure --target=arm-none-eabi --prefix=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/install --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-gnu-as --with-headers=yes --with-gnu-ld --with-native-system-header-dir=/include --with-sysroot=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/install/arm-none-eabi --with-multilib-list=aprofile,rmprofile --with-libiconv-prefix=/data/jenkins/workspace/GNU-toolchain/arm-13/build-mingw-arm-none-eabi/host-tools --host=i686-w64-mingw32 --with-pkgversion='Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)' --with-bugurl=https://bugs.linaro.org/
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 13.2.1 20231009 (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7))

Tags: cortex
Sergei (ksergeyp)
Changed in gcc-arm-embedded:
assignee: nobody → Sergei (ksergeyp)
status: New → Opinion
status: Opinion → New
tags: added: arm
Sergei (ksergeyp)
tags: added: cortex
removed: arm
Changed in newlib:
assignee: nobody → Sergei (ksergeyp)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.