radv: use ac_build_imad()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Samuel Pitoiset
2018-08-21 09:49:02 +02:00
parent d87fe1f0fd
commit 0608349232

View File

@@ -402,10 +402,8 @@ get_tcs_out_current_patch_offset(struct radv_shader_context *ctx)
LLVMValueRef patch_stride = get_tcs_out_patch_stride(ctx); LLVMValueRef patch_stride = get_tcs_out_patch_stride(ctx);
LLVMValueRef rel_patch_id = get_rel_patch_id(ctx); LLVMValueRef rel_patch_id = get_rel_patch_id(ctx);
return LLVMBuildAdd(ctx->ac.builder, patch0_offset, return ac_build_imad(&ctx->ac, patch_stride, rel_patch_id,
LLVMBuildMul(ctx->ac.builder, patch_stride, patch0_offset);
rel_patch_id, ""),
"");
} }
static LLVMValueRef static LLVMValueRef
@@ -416,10 +414,8 @@ get_tcs_out_current_patch_data_offset(struct radv_shader_context *ctx)
LLVMValueRef patch_stride = get_tcs_out_patch_stride(ctx); LLVMValueRef patch_stride = get_tcs_out_patch_stride(ctx);
LLVMValueRef rel_patch_id = get_rel_patch_id(ctx); LLVMValueRef rel_patch_id = get_rel_patch_id(ctx);
return LLVMBuildAdd(ctx->ac.builder, patch0_patch_data_offset, return ac_build_imad(&ctx->ac, patch_stride, rel_patch_id,
LLVMBuildMul(ctx->ac.builder, patch_stride, patch0_patch_data_offset);
rel_patch_id, ""),
"");
} }
#define MAX_ARGS 23 #define MAX_ARGS 23
@@ -1230,9 +1226,8 @@ radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index,
} else } else
stride = LLVMConstInt(ctx->ac.i32, layout->binding[binding].size, false); stride = LLVMConstInt(ctx->ac.i32, layout->binding[binding].size, false);
offset = LLVMConstInt(ctx->ac.i32, base_offset, false); offset = ac_build_imad(&ctx->ac, index, stride,
index = LLVMBuildMul(ctx->ac.builder, index, stride, ""); LLVMConstInt(ctx->ac.i32, base_offset, false));
offset = LLVMBuildAdd(ctx->ac.builder, offset, index, "");
desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset); desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset);
desc_ptr = ac_cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32); desc_ptr = ac_cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32);
@@ -1297,11 +1292,8 @@ static LLVMValueRef get_tcs_tes_buffer_address(struct radv_shader_context *ctx,
constant16 = LLVMConstInt(ctx->ac.i32, 16, false); constant16 = LLVMConstInt(ctx->ac.i32, 16, false);
param_stride = calc_param_stride(ctx, vertex_index); param_stride = calc_param_stride(ctx, vertex_index);
if (vertex_index) { if (vertex_index) {
base_addr = LLVMBuildMul(ctx->ac.builder, rel_patch_id, base_addr = ac_build_imad(&ctx->ac, rel_patch_id,
vertices_per_patch, ""); vertices_per_patch, vertex_index);
base_addr = LLVMBuildAdd(ctx->ac.builder, base_addr,
vertex_index, "");
} else { } else {
base_addr = rel_patch_id; base_addr = rel_patch_id;
} }