mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-30 07:10:27 +01:00
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:
parent
ae34627e54
commit
f6008645f6
1 changed files with 2 additions and 2 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue