public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kirdyankinsp at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [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 Date: Wed, 27 Dec 2023 07:03:02 +0000 [thread overview] Message-ID: <bug-113155-4@http.gcc.gnu.org/bugzilla/> (raw) 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; }
next reply other threads:[~2023-12-27 7:03 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-27 7:03 kirdyankinsp at gmail dot com [this message] 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
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=bug-113155-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).