nir/lower_io: fix bounds checking for 64bit_bounded_global

If the offset is negative like it's the case in

dEQP-VK.robustness.robustness2.bind.notemplate.r32i.unroll.volatile.storage_buffer_dynamic.readwrite.no_fmt_qual.len_256.samples_1.1d.comp

we end up passing the bounds checking condition because it's using
signed integers.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Suggested-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Cc: mesa-stable
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20762>
(cherry picked from commit ff34e96701)
This commit is contained in:
Lionel Landwerlin 2023-01-17 23:42:03 +02:00 committed by Eric Engestrom
parent 89e679803b
commit 90e1c36baa
2 changed files with 4 additions and 3 deletions

View file

@ -2956,7 +2956,7 @@
"description": "nir/lower_io: fix bounds checking for 64bit_bounded_global",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -1184,8 +1184,9 @@ addr_is_in_bounds(nir_builder *b, nir_ssa_def *addr,
{
assert(addr_format == nir_address_format_64bit_bounded_global);
assert(addr->num_components == 4);
return nir_ige(b, nir_channel(b, addr, 2),
nir_iadd_imm(b, nir_channel(b, addr, 3), size));
assert(size > 0);
return nir_ult(b, nir_iadd_imm(b, nir_channel(b, addr, 3), size - 1),
nir_channel(b, addr, 2));
}
static void