From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B0153858D35; Wed, 27 Dec 2023 07:03:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B0153858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703660583; bh=FyWGSeb1XvuBAvb5lwf0oF+nt+i/BOEmh3pQkhN5CmM=; h=From:To:Subject:Date:From; b=P112nykl5MsRO7N4EcZKf8UdACopZdJjoL1WO09qe6I3hwJ01mKxs8ZYl+DlX9Kyo AS73xb20Z2H3x5dvNHrG74F6/6k7Jqzh0eXmLvBXCN175L1sYt0wtN+yymA3mRWNiK NHSMqPvmODi6GZS9q9OmEst50++nKlhFdr4/0weY= From: "kirdyankinsp at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgcc X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kirdyankinsp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113155 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 implementat= ion adds several kilobytes of code, which is unacceptable for embeded systems w= ith 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 t= hat have hardware "float" support and do not have a hardware "double". The curr= ent 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 =3D *((uint32_t*) &f); uint32_t exp; result &=3D (~0x80000000); exp =3D result >> 23; result &=3D 0x7FFFFF; result |=3D 0x800000; #if CHECK_UB if (exp =3D=3D 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 <=3D 0x96U) { exp =3D 0x96 - exp; result >>=3D exp; return (uint64_t) result; } exp -=3D 0x96U; return (uint64_t) result << exp; }=