public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/99748] New: MVE: Wrong code at -O0 with float to integer conversion
@ 2021-03-24 10:04 acoplan at gcc dot gnu.org
  2021-03-24 10:06 ` [Bug target/99748] " acoplan at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: acoplan at gcc dot gnu.org @ 2021-03-24 10:04 UTC (permalink / raw)
  To: gcc-bugs

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

            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 = 1.0f;
  return (int)a != 1;
}

with -march=armv8.1-m.main+mve -mfloat-abi=hard. The program should return 0
but returns 1 when compiled with these options. Looking at the generated code:

main:
        @ args = 0, pretend = 0, frame = 8
        @ frame_needed = 1, uses_anonymous_args = 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 implementation
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.

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

end of thread, other threads:[~2021-04-23 11:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 10:04 [Bug target/99748] New: MVE: Wrong code at -O0 with float to integer conversion acoplan at gcc dot gnu.org
2021-03-24 10:06 ` [Bug target/99748] " acoplan at gcc dot gnu.org
2021-03-24 10:15 ` acoplan at gcc dot gnu.org
2021-03-31 14:35 ` acoplan at gcc dot gnu.org
2021-04-06  8:07 ` cvs-commit at gcc dot gnu.org
2021-04-06  8:14 ` acoplan at gcc dot gnu.org
2021-04-23 11:40 ` cvs-commit at gcc dot gnu.org
2021-04-23 11:41 ` acoplan at gcc dot gnu.org

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