[Mesa-dev] [PATCH 09/22] glsl: Add ir_unop_neg to get_range

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


V2: Put in alphabetic order
    Add some air for readability

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/opt_minmax.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 04ae0c0..43d6061 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -336,6 +336,17 @@ get_range(ir_rvalue *rval)
          low = new(mem_ctx) ir_constant(0.0f);
          return minmax_range(low, high);
 
+      case ir_unop_neg:
+         r0 = get_range(expr->operands[0]);
+
+         if (r0.high)
+            low = neg(r0.high)->constant_expression_value();
+
+         if (r0.low)
+            high = neg(r0.low)->constant_expression_value();
+
+         return minmax_range(low, high);
+
       case ir_unop_saturate:
          r0 = minmax_range(new(mem_ctx) ir_constant(0.0f),
                            new(mem_ctx) ir_constant(1.0f));
-- 
2.2.1



More information about the mesa-dev mailing list