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

Author: Ian Romanick <[email protected]>
Date:   Mon Aug  9 09:54:47 2010 -0700

ir_algebraic: Convert ir_unop_logic_not handler to use a switch statement

Currently only ir_binop_equal and ir_binop_nequal are supported, but
soon all of the relational operators will be added.  Making this
change now will simplify those commits.

---

 src/glsl/ir_algebraic.cpp |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp
index a6ecad7..d9e7b68 100644
--- a/src/glsl/ir_algebraic.cpp
+++ b/src/glsl/ir_algebraic.cpp
@@ -161,22 +161,32 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir)
    }
 
    switch (ir->operation) {
-   case ir_unop_logic_not:
-      if (op_expr[0] && op_expr[0]->operation == ir_binop_equal) {
-        this->progress = true;
-        return new(ir) ir_expression(ir_binop_nequal,
-                                     ir->type,
-                                     op_expr[0]->operands[0],
-                                     op_expr[0]->operands[1]);
+   case ir_unop_logic_not: {
+      enum ir_expression_operation new_op = ir_unop_logic_not;
+
+      if (op_expr[0] == NULL)
+        break;
+
+      switch (op_expr[0]->operation) {
+      case ir_binop_equal:   new_op = ir_binop_nequal;  break;
+      case ir_binop_nequal:  new_op = ir_binop_equal;   break;
+
+      default:
+        /* The default case handler is here to silence a warning from GCC.
+         */
+        break;
       }
-      if (op_expr[0] && op_expr[0]->operation == ir_binop_nequal) {
+
+      if (new_op != ir_unop_logic_not) {
         this->progress = true;
-        return new(ir) ir_expression(ir_binop_equal,
+        return new(ir) ir_expression(new_op,
                                      ir->type,
                                      op_expr[0]->operands[0],
                                      op_expr[0]->operands[1]);
       }
+
       break;
+   }
 
    case ir_binop_add:
       if (is_vec_zero(op_const[0])) {

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to