Skip to content

Commit

Permalink
Fix unsafe_trunc test for NaN16 (#56630)
Browse files Browse the repository at this point in the history
The return value of the LLVM instruction `fptosi`
(https://llvm.org/docs/LangRef.html#fptosi-to-instruction) does not
guarantee that the truncation of `NaN` is 0, so we relax the test to
only check that the output has the expected type.

Fix #56582.
  • Loading branch information
giordano authored Nov 21, 2024
1 parent 873a1e4 commit 1fb8df6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/float16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ end
@test unsafe_trunc(Int16, Float16(3)) === Int16(3)
@test unsafe_trunc(UInt128, Float16(3)) === UInt128(3)
@test unsafe_trunc(Int128, Float16(3)) === Int128(3)
@test unsafe_trunc(Int16, NaN16) === Int16(0) #18771
# `unsafe_trunc` of `NaN` can be any value, see #56582
@test unsafe_trunc(Int16, NaN16) isa Int16 # #18771
end
@testset "fma and muladd" begin
@test fma(Float16(0.1),Float16(0.9),Float16(0.5)) fma(0.1,0.9,0.5)
Expand Down

0 comments on commit 1fb8df6

Please sign in to comment.