public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/113155] New: large overhead for cast float to uint64_t. Arm cortex-m4 (ARMv7E-M, fpv4-sp-d16, ieee 754). Compiler: arm-none-eabi-gcc
@ 2023-12-27  7:03 kirdyankinsp at gmail dot com
  2023-12-27  7:17 ` [Bug target/113155] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kirdyankinsp at gmail dot com @ 2023-12-27  7:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113155

            Bug ID: 113155
           Summary: large overhead for cast float to uint64_t. Arm
                    cortex-m4 (ARMv7E-M, fpv4-sp-d16, ieee 754). Compiler:
                    arm-none-eabi-gcc
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kirdyankinsp at gmail dot com
  Target Milestone: ---

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 it is necessary to separate the softfloat functions for platforms that
have hardware "float" support and do not have a hardware "double". 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 &= 0x7FFFFF;
  result |= 0x800000;
#if CHECK_UB
  if (exp == 0xFF) // if NaN or inf
  {
    return 0x8000000000000000; // ????????
  }
  if(exp > (0x96 + 40)) // if the variable value is too large
  {
    return 0x8000000000000000; // ????????
  }
#endif
  if (exp < 0x7F)
  {
    return 0;
  }
  if (exp <= 0x96U)
  {
    exp = 0x96 - exp;
    result >>= exp;
    return (uint64_t) result;
  }
  exp -= 0x96U;
  return (uint64_t) result << exp;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-28  6:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-27  7:03 [Bug libgcc/113155] New: large overhead for cast float to uint64_t. Arm cortex-m4 (ARMv7E-M, fpv4-sp-d16, ieee 754). Compiler: arm-none-eabi-gcc kirdyankinsp at gmail dot com
2023-12-27  7:17 ` [Bug target/113155] " pinskia at gcc dot gnu.org
2023-12-27  7:23 ` pinskia at gcc dot gnu.org
2023-12-27  7:24 ` pinskia at gcc dot gnu.org
2023-12-27  7:34 ` pinskia at gcc dot gnu.org
2023-12-28  5:07 ` kirdyankinsp at gmail dot com
2023-12-28  6:22 ` pinskia at gcc dot gnu.org
2023-12-28  6:48 ` kirdyankinsp at gmail dot com

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).