From feffd0e445a375aa23d15bf27a0ba5a3d53d3e8b Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 23 Dec 2025 15:57:03 -0800 Subject: [PATCH] nir: Avoid UB of (int)0xff << 24 evaluating usadd_4x8_vc4. Caught by UBSan on introduction of nir_opt_algebraic_pattern_test. Part-of: --- src/compiler/nir/nir_opcodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 4f4ee3d6ebc..a70b106af40 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -1502,7 +1502,7 @@ if (!isnormal(dst)) binop("usadd_4x8_vc4", tint32, _2src_commutative + associative, """ dst = 0; for (int i = 0; i < 32; i += 8) { - dst |= MIN2(((src0 >> i) & 0xff) + ((src1 >> i) & 0xff), 0xff) << i; + dst |= (uint32_t)MIN2(((src0 >> i) & 0xff) + ((src1 >> i) & 0xff), 0xff) << i; } """)