Mesa (master): radv: use ac_build_imad()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 22 07:17:05 UTC 2018


Module: Mesa
Branch: master
Commit: 0608349232ab4598e81b33bd8128c226a632528b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0608349232ab4598e81b33bd8128c226a632528b

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Tue Aug 21 09:49:02 2018 +0200

radv: use ac_build_imad()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/amd/vulkan/radv_nir_to_llvm.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index 8bf3ae0f15..4940e3230f 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -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 rel_patch_id = get_rel_patch_id(ctx);
 
-	return LLVMBuildAdd(ctx->ac.builder, patch0_offset,
-			    LLVMBuildMul(ctx->ac.builder, patch_stride,
-					 rel_patch_id, ""),
-			    "");
+	return ac_build_imad(&ctx->ac, patch_stride, rel_patch_id,
+			     patch0_offset);
 }
 
 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 rel_patch_id = get_rel_patch_id(ctx);
 
-	return LLVMBuildAdd(ctx->ac.builder, patch0_patch_data_offset,
-			    LLVMBuildMul(ctx->ac.builder, patch_stride,
-					 rel_patch_id, ""),
-			    "");
+	return ac_build_imad(&ctx->ac, patch_stride, rel_patch_id,
+			     patch0_patch_data_offset);
 }
 
 #define MAX_ARGS 23
@@ -1230,9 +1226,8 @@ radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index,
 	} else
 		stride = LLVMConstInt(ctx->ac.i32, layout->binding[binding].size, false);
 
-	offset = LLVMConstInt(ctx->ac.i32, base_offset, false);
-	index = LLVMBuildMul(ctx->ac.builder, index, stride, "");
-	offset = LLVMBuildAdd(ctx->ac.builder, offset, index, "");
+	offset = ac_build_imad(&ctx->ac, index, stride,
+			       LLVMConstInt(ctx->ac.i32, base_offset, false));
 
 	desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset);
 	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);
 	param_stride = calc_param_stride(ctx, vertex_index);
 	if (vertex_index) {
-		base_addr = LLVMBuildMul(ctx->ac.builder, rel_patch_id,
-		                         vertices_per_patch, "");
-
-		base_addr = LLVMBuildAdd(ctx->ac.builder, base_addr,
-		                         vertex_index, "");
+		base_addr = ac_build_imad(&ctx->ac, rel_patch_id,
+					  vertices_per_patch, vertex_index);
 	} else {
 		base_addr = rel_patch_id;
 	}




More information about the mesa-commit mailing list