Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Source/UnitTest/test_simd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,16 @@ TEST(SuiteVfloat4, float16_to_float)

// NaNs must be preserved
EXPECT_NE(std::isnan(r.lane<3>()), 0);

// Negative numbers must keep their sign
vint4 b(0xBE00, 0xDB54, 0xFC00, 0x8000);
vfloat4 s = float16_to_float(b);

EXPECT_EQ(s.lane<0>(), -1.5);
EXPECT_EQ(s.lane<1>(), -234.5);
EXPECT_NE(std::isinf(s.lane<2>()), 0);
EXPECT_LT(s.lane<2>(), 0.0f);
EXPECT_NE(std::signbit(s.lane<3>()), 0);
}

/** @brief Test fp16 to float conversion. */
Expand Down
2 changes: 1 addition & 1 deletion Source/astcenc_vecmathlib_sse_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ static inline uint16_t float_to_float16(float a)
ASTCENC_SIMD_INLINE vfloat4 float16_to_float(vint4 a)
{
#if ASTCENC_F16C >= 1
__m128i packed = _mm_packs_epi32(a.m, a.m);
__m128i packed = _mm_packus_epi32(a.m, a.m);
__m128 f32 = _mm_cvtph_ps(packed);
return vfloat4(f32);
#else
Expand Down