From f6008645f6e2bad4aeb7bdacfbddbf0217754b3c Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 6 Jan 2026 12:59:25 -0800 Subject: [PATCH] nir: Fix constant evaluation of non-32-bit bitfield_extract. Caught by nir_opt_algebraic_pattern_tests. Fixes: 226b0e28dbe9 ("nir: generalize bitfield insert/extract sizes") Reviewed-by: Alyssa Rosenzweig 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 77ceacf83be..46ac53905b7 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -1169,7 +1169,7 @@ unsigned base = src0; int offset = src1, bits = src2; if (bits == 0) { dst = 0; -} else if (bits < 0 || offset < 0 || offset + bits > 32) { +} else if (bits < 0 || offset < 0 || offset + bits > bit_size) { dst = 0; /* undefined per the spec */ } else { dst = (base >> offset) & ((1ull << bits) - 1); @@ -1181,7 +1181,7 @@ int base = src0; int offset = src1, bits = src2; if (bits == 0) { dst = 0; -} else if (offset < 0 || bits < 0 || offset + bits > 32) { +} else if (offset < 0 || bits < 0 || offset + bits > bit_size) { dst = 0; } else { dst = (base << (32 - offset - bits)) >> (32 - bits); /* use sign-extending shift */