intel/brw: Fix undefined left shift of negative value in brw_texture_offset

When -fsanitize=shift is used, many instances of the following are
produced:

src/intel/compiler/brw_fs_nir.cpp:114:30: runtime error: left shift of negative value -1

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30333>
This commit is contained in:
Ian Romanick
2024-07-22 19:18:40 -07:00
parent 4f24c2707f
commit e6669467b8

View File

@@ -111,7 +111,7 @@ brw_texture_offset(const nir_tex_instr *tex, unsigned src,
return false;
const unsigned shift = 4 * (2 - i);
offset_bits |= (offset << shift) & (0xF << shift);
offset_bits |= (offset & 0xF) << shift;
}
*offset_bits_out = offset_bits;