[Mesa-dev] [PATCH 6/6] Remove redudant comparisons

Constantine Charlamov Hi-Angel at yandex.ru
Sun Feb 26 20:31:49 UTC 2017


From: Hi-Angel <Hi-Angel at yandex.ru>

Signed-off-by: Constantine Charlamov <Hi-Angel at yandex.ru>
---
 src/gallium/drivers/r600/r600_shader.c | 64 ++++++++--------------------------
 1 file changed, 14 insertions(+), 50 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 3616de572b..9afaaa57ba 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -745,10 +745,7 @@ static int single_alu_op2(struct r600_shader_ctx *ctx, int op,
 	alu.dst.chan = dst_chan;
 	alu.dst.write = 1;
 	alu.last = 1;
-	r = r600_bytecode_add_alu(ctx->bc, &alu);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu(ctx->bc, &alu);
 }
 
 /* execute a single slot ALU calculation */
@@ -759,7 +756,6 @@ static int single_alu_op3(struct r600_shader_ctx *ctx, int op,
 			  int src2_sel, unsigned src2_chan_val)
 {
 	struct r600_bytecode_alu alu;
-	int r;
 
 	/* validate this for other ops */
 	assert(op == ALU_OP3_MULADD_UINT24);
@@ -784,10 +780,7 @@ static int single_alu_op3(struct r600_shader_ctx *ctx, int op,
 	alu.dst.chan = dst_chan;
 	alu.is_op3 = 1;
 	alu.last = 1;
-	r = r600_bytecode_add_alu(ctx->bc, &alu);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu(ctx->bc, &alu);
 }
 
 /* put it in temp_reg.x */
@@ -795,21 +788,16 @@ static int get_lds_offset0(struct r600_shader_ctx *ctx,
 			   int rel_patch_chan,
 			   int temp_reg, bool is_patch_var)
 {
-	int r;
-
 	/* MUL temp.x, patch_stride (input_vals.x), rel_patch_id (r0.y (tcs)) */
 	/* ADD
 	   Dimension - patch0_offset (input_vals.z),
 	   Non-dim - patch0_data_offset (input_vals.w)
 	*/
-	r = single_alu_op3(ctx, ALU_OP3_MULADD_UINT24,
-			   temp_reg, 0,
-			   ctx->tess_output_info, 0,
-			   0, rel_patch_chan,
-			   ctx->tess_output_info, is_patch_var ? 3 : 2);
-	if (r)
-		return r;
-	return 0;
+	return single_alu_op3(ctx, ALU_OP3_MULADD_UINT24,
+			      temp_reg, 0,
+			      ctx->tess_output_info, 0,
+			      0, rel_patch_chan,
+			      ctx->tess_output_info, is_patch_var ? 3 : 2);
 }
 
 static inline int get_address_file_reg(struct r600_shader_ctx *ctx, int index)
@@ -839,16 +827,12 @@ static int vs_add_primid_output(struct r600_shader_ctx *ctx, int prim_id_sid)
 static int tgsi_barrier(struct r600_shader_ctx *ctx)
 {
 	struct r600_bytecode_alu alu;
-	int r;
 
 	memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 	alu.op = ctx->inst_info->op;
 	alu.last = 1;
 
-	r = r600_bytecode_add_alu(ctx->bc, &alu);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu(ctx->bc, &alu);
 }
 
 static int tgsi_declaration(struct r600_shader_ctx *ctx)
@@ -1793,10 +1777,7 @@ static int fetch_tes_input(struct r600_shader_ctx *ctx, struct tgsi_full_src_reg
 	if (r)
 		return r;
 
-	r = do_lds_fetch_values(ctx, temp_reg, dst_reg);
-	if (r)
-		return r;
-	return 0;
+	return do_lds_fetch_values(ctx, temp_reg, dst_reg);
 }
 
 static int fetch_tcs_input(struct r600_shader_ctx *ctx, struct tgsi_full_src_register *src, unsigned int dst_reg)
@@ -1819,10 +1800,7 @@ static int fetch_tcs_input(struct r600_shader_ctx *ctx, struct tgsi_full_src_reg
 	if (r)
 		return r;
 
-	r = do_lds_fetch_values(ctx, temp_reg, dst_reg);
-	if (r)
-		return r;
-	return 0;
+	return do_lds_fetch_values(ctx, temp_reg, dst_reg);
 }
 
 static int fetch_tcs_output(struct r600_shader_ctx *ctx, struct tgsi_full_src_register *src, unsigned int dst_reg)
@@ -1841,10 +1819,7 @@ static int fetch_tcs_output(struct r600_shader_ctx *ctx, struct tgsi_full_src_re
 	if (r)
 		return r;
 
-	r = do_lds_fetch_values(ctx, temp_reg, dst_reg);
-	if (r)
-		return r;
-	return 0;
+	return do_lds_fetch_values(ctx, temp_reg, dst_reg);
 }
 
 static int tgsi_split_lds_inputs(struct r600_shader_ctx *ctx)
@@ -4493,10 +4468,7 @@ static int tgsi_setup_trig(struct r600_shader_ctx *ctx)
 	}
 
 	alu.last = 1;
-	r = r600_bytecode_add_alu(ctx->bc, &alu);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu(ctx->bc, &alu);
 }
 
 static int cayman_trig(struct r600_shader_ctx *ctx)
@@ -6679,7 +6651,6 @@ static int r600_do_buffer_txq(struct r600_shader_ctx *ctx)
 {
 	struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
 	struct r600_bytecode_alu alu;
-	int r;
 	int id = tgsi_tex_get_src_gpr(ctx, 1);
 
 	memset(&alu, 0, sizeof(struct r600_bytecode_alu));
@@ -6697,10 +6668,7 @@ static int r600_do_buffer_txq(struct r600_shader_ctx *ctx)
 	alu.src[0].kc_bank = R600_BUFFER_INFO_CONST_BUFFER;
 	tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
 	alu.last = 1;
-	r = r600_bytecode_add_alu(ctx->bc, &alu);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu(ctx->bc, &alu);
 }
 
 static int tgsi_tex(struct r600_shader_ctx *ctx)
@@ -8372,7 +8340,6 @@ static int tgsi_opdst(struct r600_shader_ctx *ctx)
 static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode, int alu_type)
 {
 	struct r600_bytecode_alu alu;
-	int r;
 
 	memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 	alu.op = opcode;
@@ -8389,10 +8356,7 @@ static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode, int alu_type
 
 	alu.last = 1;
 
-	r = r600_bytecode_add_alu_type(ctx->bc, &alu, alu_type);
-	if (r)
-		return r;
-	return 0;
+	return r600_bytecode_add_alu_type(ctx->bc, &alu, alu_type);
 }
 
 static int pops(struct r600_shader_ctx *ctx, int pops)
-- 
2.11.1



More information about the mesa-dev mailing list