diff options
author | Matt Turner <[email protected]> | 2013-10-27 17:09:41 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2013-12-04 20:05:44 -0800 |
commit | 9658b04fc473a9b16ede16b632e4f0b23ae90a70 (patch) | |
tree | 0bd60d94b10837e0a44dc1a71bd59b94e9cd35e5 /src/mesa | |
parent | 4532cac06a9da527549efb685c6f37ffed24ddbf (diff) |
i965/fs: Emit a MOV instead of a SEL if the sources are the same.
One program affected.
instructions in affected programs: 436 -> 428 (-1.83%)
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp index f2749945813..d3147998028 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp @@ -169,26 +169,30 @@ fs_visitor::opt_peephole_sel() break; } - /* Only the last source register can be a constant, so if the MOV in - * the "then" clause uses a constant, we need to put it in a - * temporary. - */ - fs_reg src0(then_mov[i]->src[0]); - if (src0.file == IMM) { - src0 = fs_reg(this, glsl_type::float_type); - src0.type = then_mov[i]->src[0].type; - mov_imm_inst[i] = MOV(src0, then_mov[i]->src[0]); - } - - sel_inst[i] = SEL(then_mov[i]->dst, src0, else_mov[i]->src[0]); - - if (brw->gen == 6 && if_inst->conditional_mod) { - /* For Sandybridge with IF with embedded comparison */ - sel_inst[i]->predicate = BRW_PREDICATE_NORMAL; + if (!then_mov[i]->src[0].equals(else_mov[i]->src[0])) { + /* Only the last source register can be a constant, so if the MOV + * in the "then" clause uses a constant, we need to put it in a + * temporary. + */ + fs_reg src0(then_mov[i]->src[0]); + if (src0.file == IMM) { + src0 = fs_reg(this, glsl_type::float_type); + src0.type = then_mov[i]->src[0].type; + mov_imm_inst[i] = MOV(src0, then_mov[i]->src[0]); + } + + sel_inst[i] = SEL(then_mov[i]->dst, src0, else_mov[i]->src[0]); + + if (brw->gen == 6 && if_inst->conditional_mod) { + /* For Sandybridge with IF with embedded comparison */ + sel_inst[i]->predicate = BRW_PREDICATE_NORMAL; + } else { + /* Separate CMP and IF instructions */ + sel_inst[i]->predicate = if_inst->predicate; + sel_inst[i]->predicate_inverse = if_inst->predicate_inverse; + } } else { - /* Separate CMP and IF instructions */ - sel_inst[i]->predicate = if_inst->predicate; - sel_inst[i]->predicate_inverse = if_inst->predicate_inverse; + sel_inst[i] = MOV(then_mov[i]->dst, then_mov[i]->src[0]); } } |