testsuite: Fix another ubsan warning

The expression here was a bit too dense for ubsan to figure out
what branches aren't hit.
This commit is contained in:
Matthias Clasen 2024-04-21 22:24:02 -04:00
parent deec2b6c6c
commit 5d1b8399fb

View File

@ -73,7 +73,18 @@ float_to_half (const float x)
const guint b = *(guint*)&x+0x00001000; // round-to-nearest-even
const guint e = (b&0x7F800000)>>23; // exponent
const guint m = b&0x007FFFFF; // mantissa
return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
guint n0 = 0;
guint n1 = 0;
guint n2 = 0;
if (e > 112)
n0 = (((e - 112) << 10) & 0x7C00) | m >> 13;
if (e < 113 && e > 101)
n1 = (((0x007FF000 + m) >> (125- e)) + 1) >> 1;
if (e > 143)
n2 = 0x7FFF;
return (b & 0x80000000) >> 16 | n0 | n1 | n2; // sign : normalized : denormalized : saturate
}
static gsize