[Mesa-dev] [PATCH 04/22] glsl: Change to using switch-case in get_range

Thomas Helland thomashelland90 at gmail.com
Sat Jan 3 11:18:09 PST 2015


This will make expansion easier and less cluttered.

v2: Correct missing space
---
 src/glsl/opt_minmax.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index a3b0a65..56805c0 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -271,11 +271,21 @@ static minmax_range
 get_range(ir_rvalue *rval)
 {
    ir_expression *expr = rval->as_expression();
-   if (expr && (expr->operation == ir_binop_min ||
-                expr->operation == ir_binop_max)) {
-      minmax_range r0 = get_range(expr->operands[0]);
-      minmax_range r1 = get_range(expr->operands[1]);
-      return combine_range(r0, r1, expr->operation == ir_binop_min);
+   minmax_range r0;
+   minmax_range r1;
+
+   if (expr) {
+      switch (expr->operation) {
+
+      case ir_binop_min:
+      case ir_binop_max:
+         r0 = get_range(expr->operands[0]);
+         r1 = get_range(expr->operands[1]);
+         return combine_range(r0, r1, expr->operation == ir_binop_min);
+
+      default:
+         break;
+      }
    }
 
    ir_constant *c = rval->as_constant();
-- 
2.2.1



More information about the mesa-dev mailing list