util: fix UBSan error with _mesa_bfloat16_bits_to_float

runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'

This fixes nir_opt_algebraic_pattern_test.bf2f.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Fixes: ecd2d2cf46 ("util: Add functions to convert float to/from bfloat16")
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40740>
This commit is contained in:
Rhys Perry 2026-04-07 09:46:27 +01:00 committed by Marge Bot
parent ca6edbd9c8
commit 72f2b8a034

View file

@ -63,7 +63,7 @@ static inline float
_mesa_bfloat16_bits_to_float(uint16_t bf)
{
union fi x;
x.ui = bf << 16;
x.ui = (uint32_t)bf << 16;
return x.f;
}