diff options
author | Matt Turner <[email protected]> | 2015-02-04 18:08:30 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-02-15 12:24:10 -0800 |
commit | eb47d0efd39d73d4388389d6c0ebe458160f79fa (patch) | |
tree | d90882074184d2aca6ae1d942b644e0eed34dff4 /src/mesa/drivers | |
parent | e8a6f2ad65b03eac7c030b2cd4955a162739870b (diff) |
i965: Optimize multiplication by -1 into a negated MOV.
instructions in affected programs: 968 -> 942 (-2.69%)
helped: 4
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 9 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.cpp | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index c7c6accebf6..0f1300c1cc6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2325,6 +2325,15 @@ fs_visitor::opt_algebraic() break; } + /* a * -1.0 = -a */ + if (inst->src[1].is_negative_one()) { + inst->opcode = BRW_OPCODE_MOV; + inst->src[0].negate = !inst->src[0].negate; + inst->src[1] = reg_undef; + progress = true; + break; + } + /* a * 0.0 = 0.0 */ if (inst->src[1].is_zero()) { inst->opcode = BRW_OPCODE_MOV; diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index fda8552d841..58828c3f320 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -725,6 +725,11 @@ vec4_visitor::opt_algebraic() inst->opcode = BRW_OPCODE_MOV; inst->src[1] = src_reg(); progress = true; + } else if (inst->src[1].is_negative_one()) { + inst->opcode = BRW_OPCODE_MOV; + inst->src[0].negate = !inst->src[0].negate; + inst->src[1] = src_reg(); + progress = true; } break; case BRW_OPCODE_CMP: |