From f044de2e60352e5e9866561481181d3926f201aa Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Oct 2022 11:11:57 +0200 Subject: [PATCH] ac/llvm: switch ac_build_pointer_add to LLVMBuildGEP2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cast was superfluous: GEP2 return value is a pointer to the given type. Reviewed-by: Mihai Preda Reviewed-by: Dave Airlie Reviewed-by: Qiang Yu Reviewed-by: Marek Olšák Acked-by: Samuel Pitoiset Part-of: --- src/amd/llvm/ac_llvm_build.c | 5 ++--- src/amd/llvm/ac_llvm_build.h | 2 +- src/gallium/drivers/radeonsi/si_shader_llvm_resources.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index be3b9d8f8d2..7122063d45e 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -1099,10 +1099,9 @@ LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, L return LLVMBuildGEP(ctx->builder, base_ptr, indices, 2, ""); } -LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMValueRef index) +LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr, LLVMValueRef index) { - LLVMValueRef offset_ptr = LLVMBuildGEP(ctx->builder, ptr, &index, 1, ""); - return LLVMBuildPointerCast(ctx->builder, offset_ptr, LLVMTypeOf(ptr), ""); + return LLVMBuildGEP2(ctx->builder, type, ptr, &index, 1, ""); } void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index, diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 2ba7e3df487..add6cc2ed4f 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -255,7 +255,7 @@ LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLV LLVMValueRef index); LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index); -LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMValueRef ptr, +LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr, LLVMValueRef index); void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index, diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c index 5a0ab62250a..8cbc8e5ca6f 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c @@ -279,7 +279,7 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned */ dynamic_index = LLVMBuildMul(ctx->ac.builder, dynamic_index, LLVMConstInt(ctx->ac.i64, 2, 0), ""); - list = ac_build_pointer_add(&ctx->ac, list, dynamic_index); + list = ac_build_pointer_add(&ctx->ac, ctx->ac.v8i32, list, dynamic_index); return si_load_sampler_desc(ctx, list, ctx->ac.i32_0, desc_type); }