nir: Fix constant evaluation of non-32-bit bitfield_extract.

Caught by nir_opt_algebraic_pattern_tests.

Fixes: 226b0e28db ("nir: generalize bitfield insert/extract sizes")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39076>
This commit is contained in:
Emma Anholt 2026-01-06 12:59:25 -08:00 committed by Marge Bot
parent ae34627e54
commit f6008645f6

View file

@ -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 */