From 78aae4b1bafa50fc25e4a99296d8be718ceed64c Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 27 May 2025 11:34:49 +0100 Subject: [PATCH] nir: fix signed overflow in pack_half_2x16 constant folding Without this cast, the left shift is promoted to 'int'. Fixes "left shift of 50432 by 16 places cannot be represented in type 'int'" with horizon_zero_dawn/001064f580f8e3be and UBSan. Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_opcodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index daa61c1e30f..e78b179cc2b 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -945,10 +945,10 @@ binop("umax", tuint, _2src_commutative + associative, "MAX2(src0, src1)") binop("fpow", tfloat, "", "bit_size == 64 ? pow(src0, src1) : powf(src0, src1)") binop_horiz("pack_half_2x16_split", 1, tuint32, 1, tfloat32, 1, tfloat32, - "pack_half_1x16(src0.x) | ((uint32_t)(pack_half_1x16(src1.x)) << 16)") + "pack_half_1x16(src0.x) | ((uint32_t)pack_half_1x16(src1.x) << 16)") binop_horiz("pack_half_2x16_rtz_split", 1, tuint32, 1, tfloat32, 1, tfloat32, - "pack_half_1x16_rtz(src0.x) | (uint32_t)(pack_half_1x16_rtz(src1.x) << 16)") + "pack_half_1x16_rtz(src0.x) | ((uint32_t)pack_half_1x16_rtz(src1.x) << 16)") binop_convert("pack_64_2x32_split", tuint64, tuint32, "", "src0 | ((uint64_t)src1 << 32)")