[Mesa-dev] [PATCH 16/16] glsl: Add ir_unop_rcp to get_range

Thomas Helland thomashelland90 at gmail.com
Sun Nov 16 17:52:01 PST 2014


---
 src/glsl/opt_minmax.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 466db8c..96b1e07 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -301,6 +301,30 @@ get_range(ir_rvalue *rval)
             high = neg(r0.low)->constant_expression_value();
          return minmax_range(low, high);
 
+      case ir_unop_rcp:
+         r0 = get_range(expr->operands[0]);
+         if (is_greater_than_zero(r0.low)) {
+            ir_expression *h = new(mem_ctx) ir_expression(ir_unop_rcp, r0.low);
+            high = h->constant_expression_value();
+            if (r0.high) {
+               ir_expression *l = new(mem_ctx) ir_expression(ir_unop_rcp, r0.high);
+               low = l->constant_expression_value();
+            }
+         }
+         if (is_less_than_zero(r0.low) && is_less_than_zero(r0.high)) {
+            ir_expression *h = new(mem_ctx) ir_expression(ir_unop_rcp, r0.low);
+            high = h->constant_expression_value();
+            ir_expression *l = new(mem_ctx) ir_expression(ir_unop_rcp, r0.high);
+            low = l->constant_expression_value();
+         }
+         if (is_less_than_zero(r0.low) && is_greater_than_zero(r0.high)) {
+            ir_expression *h = new(mem_ctx) ir_expression(ir_unop_rcp, r0.high);
+            high = h->constant_expression_value();
+            ir_expression *l = new(mem_ctx) ir_expression(ir_unop_rcp, r0.low);
+            low = l->constant_expression_value();
+         }
+         return minmax_range(low, high);
+
       case ir_unop_sqrt:
       case ir_unop_rsq:
       case ir_unop_exp:
-- 
2.0.3



More information about the mesa-dev mailing list