Skip to content

Addition of Float16 is wrong on armv7l #41064

@giordano

Description

@giordano
julia> Float16(-3.743e-5) + Float16(1)
Float16(3.05e-5)

@code_native Float16(-3.743e-5) + Float16(1):

        .text
; ┌ @ float.jl:324 within `+'
        push    {r11, lr}
        vpush   {d8}
        vmov    r0, s1
        vmov.f32        s16, s0
        bl      ($a)
        vmov    r1, s16
        vmov    s16, r0
        mov     r0, r1
        bl      ($a)
        vmov    s0, r0
        vadd.f32        s0, s0, s16
        vmov    r0, s0
        bl      ($a)
        uxth    r0, r0
        vmov    s0, r0
        vpop    {d8}
        pop     {r11, pc}

@code_llvm Float16(-3.743e-5) + Float16(1):

;  @ float.jl:324 within `+'
define half @"julia_+_848"(half %0, half %1) {
top:
  %2 = fpext half %0 to float
  %3 = fpext half %1 to float
  %4 = fadd float %2, %3
  %5 = fptrunc float %4 to half
  ret half %5
}

Spotted in JuliaMath/SpecialFunctions.jl#326

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingfloat16system:32-bitAffects only 32-bit systemssystem:armARMv7 and AArch64

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions