gallivm: fix lp_vec_add_offset_ptr for 32 bit builds

The function assumed ptrs are always 64 bit sized.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8267
Fixes: 442d1fe5ad ("gallivm: use masked intrinsics for global and scratch access.")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21604>
(cherry picked from commit 1aca36815e)
This commit is contained in:
Karol Herbst 2023-03-01 13:39:47 +01:00 committed by Dylan Baker
parent 5f9a416b22
commit 7fe567f98d
2 changed files with 6 additions and 3 deletions

View file

@ -3109,7 +3109,7 @@
"description": "gallivm: fix lp_vec_add_offset_ptr for 32 bit builds",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "442d1fe5ad61a82cd5fa883faf2bb76a7f07401e"
},

View file

@ -848,11 +848,14 @@ static LLVMValueRef lp_vec_add_offset_ptr(struct lp_build_nir_context *bld_base,
LLVMValueRef ptr,
LLVMValueRef offset)
{
unsigned pointer_size = 8 * sizeof(void *);
struct gallivm_state *gallivm = bld_base->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context *uint_bld = &bld_base->uint_bld;
LLVMValueRef result = LLVMBuildPtrToInt(builder, ptr, bld_base->uint64_bld.vec_type, "");
offset = LLVMBuildZExt(builder, offset, bld_base->uint64_bld.vec_type, "");
struct lp_build_context *ptr_bld = get_int_bld(bld_base, true, pointer_size);
LLVMValueRef result = LLVMBuildPtrToInt(builder, ptr, ptr_bld->vec_type, "");
if (pointer_size == 64)
offset = LLVMBuildZExt(builder, offset, ptr_bld->vec_type, "");
result = LLVMBuildAdd(builder, offset, result, "");
return global_addr_to_ptr_vec(gallivm, result, uint_bld->type.length, bit_size);
}