ac,radeonsi: use ac_build_fmad
authorMarek Olšák <marek.olsak@amd.com>
Thu, 16 Aug 2018 00:50:03 +0000 (20:50 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 22 Aug 2018 00:50:37 +0000 (20:50 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader.c

index 6d5bfb1a1be9ec02bae223aff35e09e073d038ea..c741a1ab62d9b93b22bbe35890364d02eac9613f 100644 (file)
@@ -762,8 +762,7 @@ ac_prepare_cube_coords(struct ac_llvm_context *ctx,
        if (is_array) {
                /* for cube arrays coord.z = coord.w(array_index) * 8 + face */
                /* coords_arg.w component - array_index for cube arrays */
-               LLVMValueRef tmp = LLVMBuildFMul(ctx->builder, coords_arg[3], LLVMConstReal(ctx->f32, 8.0), "");
-               coords[2] = LLVMBuildFAdd(ctx->builder, tmp, coords[2], "");
+               coords[2] = ac_build_fmad(ctx, coords_arg[3], LLVMConstReal(ctx->f32, 8.0), coords[2]);
        }
 
        memcpy(coords_arg, coords, sizeof(coords));
index 1584fef7ab7c920fb471e2e90684511150e6df02..537ac33c0444095489f24e890cdb2818e1b4f41c 100644 (file)
@@ -2853,11 +2853,8 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx,
                        interp_el = LLVMBuildBitCast(ctx->ac.builder, interp_el,
                                                     ctx->ac.f32, "");
 
-                       temp1 = LLVMBuildFMul(ctx->ac.builder, ddx_el, src_c0, "");
-                       temp1 = LLVMBuildFAdd(ctx->ac.builder, temp1, interp_el, "");
-
-                       temp2 = LLVMBuildFMul(ctx->ac.builder, ddy_el, src_c1, "");
-                       temp2 = LLVMBuildFAdd(ctx->ac.builder, temp2, temp1, "");
+                       temp1 = ac_build_fmad(&ctx->ac, ddx_el, src_c0, interp_el);
+                       temp2 = ac_build_fmad(&ctx->ac, ddy_el, src_c1, temp1);
 
                        ij_out[i] = LLVMBuildBitCast(ctx->ac.builder,
                                                     temp2, ctx->ac.i32, "");
index 24ee45f578a304b1a084bdaf46ce0c439d437681..66fe5fad2185a52f1571bef593f2d6144365d588 100644 (file)
@@ -2659,10 +2659,8 @@ static void si_llvm_emit_clipvertex(struct si_shader_context *ctx,
                                                                const_chan) * 4, 0);
                                base_elt = buffer_load_const(ctx, const_resource,
                                                             addr);
-                               args->out[chan] =
-                                       LLVMBuildFAdd(ctx->ac.builder, args->out[chan],
-                                                     LLVMBuildFMul(ctx->ac.builder, base_elt,
-                                                                   out_elts[const_chan], ""), "");
+                               args->out[chan] = ac_build_fmad(&ctx->ac, base_elt,
+                                                               out_elts[const_chan], args->out[chan]);
                        }
                }
 
@@ -4114,17 +4112,12 @@ static void build_interp_intrinsic(const struct lp_build_tgsi_action *action,
                                                                      ddxy_out, iy_ll, "");
                        LLVMValueRef interp_el = LLVMBuildExtractElement(ctx->ac.builder,
                                                                         interp_param, ix_ll, "");
-                       LLVMValueRef temp1, temp2;
+                       LLVMValueRef temp;
 
                        interp_el = ac_to_float(&ctx->ac, interp_el);
 
-                       temp1 = LLVMBuildFMul(ctx->ac.builder, ddx_el, offset_x, "");
-
-                       temp1 = LLVMBuildFAdd(ctx->ac.builder, temp1, interp_el, "");
-
-                       temp2 = LLVMBuildFMul(ctx->ac.builder, ddy_el, offset_y, "");
-
-                       ij_out[i] = LLVMBuildFAdd(ctx->ac.builder, temp2, temp1, "");
+                       temp = ac_build_fmad(&ctx->ac, ddx_el, offset_x, interp_el);
+                       ij_out[i] = ac_build_fmad(&ctx->ac, ddy_el, offset_y, temp);
                }
                interp_param = ac_build_gather_values(&ctx->ac, ij_out, 2);
        }