From 90e1c36baadde0d4c33d5c8be433be0cdd9f58e9 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 17 Jan 2023 23:42:03 +0200 Subject: [PATCH] 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 Suggested-by: Jason Ekstrand Cc: mesa-stable Reviewed-by: Alyssa Rosenzweig Reviewed-by: Reviewed-by: Emma Anholt Reviewed-by: Jason Ekstrand Part-of: (cherry picked from commit ff34e96701ef8f6e52755685a5ef9425c0229cfd) --- .pick_status.json | 2 +- src/compiler/nir/nir_lower_io.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e5073f0beb2..793209a11a0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 }, diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index e0347469e8b..423a153e4e2 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -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