From 58480354432e8a0ee7b8ad80a1d1ae4ec01edfe6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 18 Nov 2024 01:29:50 -0800 Subject: [PATCH] brw: Fix try_rebuild_source's ult32/ushr handling to use unsigned types We were accidentally doing a signed integer comparison here for ult32, or a sign-extending shift for ushr. One notable bit of fallout was that load_global_uniform_block_intel address calculations broke on platforms that don't have native 64-bit integer support, as the iadd64 lowering for "do I need to carry?" was using ult32...and performing the wrong comparison. We spotted this in Borderlands 3 on Alchemist once we turned on other optimizations. Thanks to Lionel Landwerlin for helping spot the problem! Fixes: c7b312ad45 ("brw: factor out source extraction for rematerialization") Fixes: 339630ab05 ("brw: enable A64 loads source rematerialization") Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_fs_nir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index 373b33e73db..433e5b67f2e 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -4816,7 +4816,7 @@ try_rebuild_source(nir_to_brw_state &ntb, const brw::fs_builder &bld, } case nir_op_ushr: { enum brw_reg_type utype = - brw_type_with_size(srcs[0].type, + brw_type_with_size(BRW_TYPE_UD, brw_type_size_bits(srcs[0].type)); ubld.SHR(retype(srcs[0], utype), retype(srcs[1], utype), @@ -4834,10 +4834,10 @@ try_rebuild_source(nir_to_brw_state &ntb, const brw::fs_builder &bld, case nir_op_ult32: { if (brw_type_size_bits(srcs[0].type) != 32) break; - brw_reg dst = ubld.vgrf(srcs[0].type); enum brw_reg_type utype = - brw_type_with_size(srcs[0].type, + brw_type_with_size(BRW_TYPE_UD, brw_type_size_bits(srcs[0].type)); + brw_reg dst = ubld.vgrf(utype); ntb.resource_insts[def->index] = ubld.CMP(dst, retype(srcs[0], utype),