From 72f2b8a034235ff0942fcca8646ad2bb66c8b454 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 7 Apr 2026 09:46:27 +0100 Subject: [PATCH] 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 Fixes: ecd2d2cf46df ("util: Add functions to convert float to/from bfloat16") Reviewed-by: Georg Lehmann Part-of: --- src/util/bfloat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/bfloat.h b/src/util/bfloat.h index 886d55fb8ba..013c38e7e24 100644 --- a/src/util/bfloat.h +++ b/src/util/bfloat.h @@ -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; }