ac/llvm: switch ac_build_pointer_add to LLVMBuildGEP2

The cast was superfluous: GEP2 return value is a pointer to
the given type.

Reviewed-by: Mihai Preda <mhpreda@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19035>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2022-10-06 11:11:57 +02:00
committed by Marge Bot
parent f68b18f285
commit f044de2e60
3 changed files with 4 additions and 5 deletions

View File

@@ -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, ""); 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 LLVMBuildGEP2(ctx->builder, type, ptr, &index, 1, "");
return LLVMBuildPointerCast(ctx->builder, offset_ptr, LLVMTypeOf(ptr), "");
} }
void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index, void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index,

View File

@@ -255,7 +255,7 @@ LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLV
LLVMValueRef index); LLVMValueRef index);
LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, 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); LLVMValueRef index);
void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index, void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index,

View File

@@ -279,7 +279,7 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned
*/ */
dynamic_index = dynamic_index =
LLVMBuildMul(ctx->ac.builder, dynamic_index, LLVMConstInt(ctx->ac.i64, 2, 0), ""); 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); return si_load_sampler_desc(ctx, list, ctx->ac.i32_0, desc_type);
} }