brw/copy: Fix handling of offset in extract_imm

The offset is measured in bytes. Some of the code here acted as though
it were measured in src.type units. Also modify the assertion to check
that all extracted bits come from data in the immediate value.

Fixes: 580e1c592d ("intel/brw: Introduce a new SSA-based copy propagation pass")
Fixes: da395e6985 ("intel/brw: Fix extract_imm for subregion reads of 64-bit immediates")

Yes, I missed this error *twice* in code review.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33049>
This commit is contained in:
Ian Romanick 2025-01-24 10:43:28 -08:00 committed by Marge Bot
parent 57d47f717a
commit ac4b93571c

View file

@ -1739,9 +1739,12 @@ extract_imm(brw_reg val, brw_reg_type type, unsigned offset)
if (offset == 0 || bitsize == brw_type_size_bits(val.type))
return val;
assert(bitsize < brw_type_size_bits(val.type));
/* The whole extracted value must come from bits that acutally exist in the
* original immediate value.
*/
assert((8 * offset) + bitsize <= brw_type_size_bits(val.type));
val.u64 = (val.u64 >> (bitsize * offset)) & ((1ull << bitsize) - 1);
val.u64 = (val.u64 >> (8 * offset)) & ((1ull << bitsize) - 1);
return val;
}