From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C1980386181D; Wed, 24 Mar 2021 10:04:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1980386181D From: "acoplan at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99748] New: MVE: Wrong code at -O0 with float to integer conversion Date: Wed, 24 Mar 2021 10:04:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: acoplan at gcc dot gnu.org 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Mar 2021 10:04:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99748 Bug ID: 99748 Summary: MVE: Wrong code at -O0 with float to integer conversion Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- GCC miscompiles the following testcase: int main() { float a =3D 1.0f; return (int)a !=3D 1; } with -march=3Darmv8.1-m.main+mve -mfloat-abi=3Dhard. The program should ret= urn 0 but returns 1 when compiled with these options. Looking at the generated co= de: main: @ args =3D 0, pretend =3D 0, frame =3D 8 @ frame_needed =3D 1, uses_anonymous_args =3D 0 push {r7, lr} sub sp, sp, #8 add r7, sp, #0 mov r3, #1065353216 str r3, [r7, #4] @ float vldr.32 s0, [r7, #4] bl __aeabi_f2iz mov r3, r0 cmp r3, #1 ite ne movne r3, #1 moveq r3, #0 uxtb r3, r3 mov r0, r3 adds r7, r7, #8 mov sp, r7 @ sp needed pop {r7, pc} .size main, .-main we use the aeabi_f2iz libcall to do the float to integer conversion, passing the argument in the s0 (VFP) register. However, looking at the implementati= on of aeabi_f2iz in libgcc/config/arm/ieee754-sf.S, the function appears to be expecting its argument in the GPR r0. So we do the conversion on whatever happens to be in r0 when the libcall is made.=