Mesa (master): i965/fs: Change fs_visitor::emit_lrp to use MAC for gen<6

Matt Turner mattst88 at kemper.freedesktop.org
Thu Apr 17 05:44:56 UTC 2014


Module: Mesa
Branch: master
Commit: a6860100b87415ab510d0d210cabfeeccebc9a0a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6860100b87415ab510d0d210cabfeeccebc9a0a

Author: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Date:   Fri Mar 28 15:28:33 2014 +0200

i965/fs: Change fs_visitor::emit_lrp to use MAC for gen<6

This allows us to emit ADD/MUL/MAC instead of MUL/ADD/MUL/ADD,
saving one instruction and two temporary registers.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 63a0ae5..2aa3acd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -221,18 +221,15 @@ fs_visitor::emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y,
        !y.is_valid_3src() ||
        !a.is_valid_3src()) {
       /* We can't use the LRP instruction.  Emit x*(1-a) + y*a. */
-      fs_reg y_times_a           = fs_reg(this, glsl_type::float_type);
       fs_reg one_minus_a         = fs_reg(this, glsl_type::float_type);
-      fs_reg x_times_one_minus_a = fs_reg(this, glsl_type::float_type);
-
-      emit(MUL(y_times_a, y, a));
 
       fs_reg negative_a = a;
       negative_a.negate = !a.negate;
-      emit(ADD(one_minus_a, negative_a, fs_reg(1.0f)));
-      emit(MUL(x_times_one_minus_a, x, one_minus_a));
 
-      emit(ADD(dst, x_times_one_minus_a, y_times_a));
+      emit(ADD(one_minus_a, negative_a, fs_reg(1.0f)));
+      fs_inst *mul = emit(MUL(reg_null_f, y, a));
+      mul->writes_accumulator = true;
+      emit(MAC(dst, x, one_minus_a));
    } else {
       /* The LRP instruction actually does op1 * op0 + op2 * (1 - op0), so
        * we need to reorder the operands.




More information about the mesa-commit mailing list