diff options
author | Matt Turner <[email protected]> | 2014-11-09 17:27:52 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-02-17 20:44:09 -0800 |
commit | bb33a31c3830945ae768ebdaeb686291bdf897fa (patch) | |
tree | 538c005d173524fcfafe2fb3c4fd50245499c841 /src | |
parent | 8cfd1e2ac6b0d509d34c7d155a95016cd80338ed (diff) |
i965/fs: Add algebraic optimizations for MAD.
total instructions in shared programs: 5764176 -> 5763808 (-0.01%)
instructions in affected programs: 25121 -> 24753 (-1.46%)
helped: 164
HURT: 2
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 22cd77deea5..c46e1d73fd4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2343,6 +2343,14 @@ fs_visitor::opt_algebraic() break; } + if (inst->src[0].file == IMM) { + assert(inst->src[0].type == BRW_REGISTER_TYPE_F); + inst->opcode = BRW_OPCODE_MOV; + inst->src[0].fixed_hw_reg.dw1.f *= inst->src[1].fixed_hw_reg.dw1.f; + inst->src[1] = reg_undef; + progress = true; + break; + } break; case BRW_OPCODE_ADD: if (inst->src[1].file != IMM) @@ -2355,6 +2363,15 @@ fs_visitor::opt_algebraic() progress = true; break; } + + if (inst->src[0].file == IMM) { + assert(inst->src[0].type == BRW_REGISTER_TYPE_F); + inst->opcode = BRW_OPCODE_MOV; + inst->src[0].fixed_hw_reg.dw1.f += inst->src[1].fixed_hw_reg.dw1.f; + inst->src[1] = reg_undef; + progress = true; + break; + } break; case BRW_OPCODE_OR: if (inst->src[0].equals(inst->src[1])) { @@ -2429,6 +2446,32 @@ fs_visitor::opt_algebraic() } } break; + case BRW_OPCODE_MAD: + if (inst->src[1].is_zero() || inst->src[2].is_zero()) { + inst->opcode = BRW_OPCODE_MOV; + inst->src[1] = reg_undef; + inst->src[2] = reg_undef; + progress = true; + } else if (inst->src[0].is_zero()) { + inst->opcode = BRW_OPCODE_MUL; + inst->src[0] = inst->src[2]; + inst->src[2] = reg_undef; + } else if (inst->src[1].is_one()) { + inst->opcode = BRW_OPCODE_ADD; + inst->src[1] = inst->src[2]; + inst->src[2] = reg_undef; + progress = true; + } else if (inst->src[2].is_one()) { + inst->opcode = BRW_OPCODE_ADD; + inst->src[2] = reg_undef; + progress = true; + } else if (inst->src[1].file == IMM && inst->src[2].file == IMM) { + inst->opcode = BRW_OPCODE_ADD; + inst->src[1].fixed_hw_reg.dw1.f *= inst->src[2].fixed_hw_reg.dw1.f; + inst->src[2] = reg_undef; + progress = true; + } + break; case SHADER_OPCODE_RCP: { fs_inst *prev = (fs_inst *)inst->prev; if (prev->opcode == SHADER_OPCODE_SQRT) { |