Mesa (master): ir_to_mesa: Implement ir_unop_logic_not using 1-x

Ian Romanick idr at kemper.freedesktop.org
Tue Aug 16 23:47:53 UTC 2011


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sat Jul 30 10:48:10 2011 -0700

ir_to_mesa: Implement ir_unop_logic_not using 1-x

Since our logic values are 0.0 (false) and 1.0 (true), 1.0 - x
accurately implements logical not.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/program/ir_to_mesa.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1ef609f..f03ea7a 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1135,7 +1135,13 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
 
    switch (ir->operation) {
    case ir_unop_logic_not:
-      emit(ir, OPCODE_SEQ, result_dst, op[0], src_reg_for_float(0.0));
+      /* Previously 'SEQ dst, src, 0.0' was used for this.  However, many
+       * older GPUs implement SEQ using multiple instructions (i915 uses two
+       * SGE instructions and a MUL instruction).  Since our logic values are
+       * 0.0 and 1.0, 1-x also implements !x.
+       */
+      op[0].negate = ~op[0].negate;
+      emit(ir, OPCODE_ADD, result_dst, op[0], src_reg_for_float(1.0));
       break;
    case ir_unop_neg:
       op[0].negate = ~op[0].negate;




More information about the mesa-commit mailing list