[Mesa-dev] [PATCH 14/16] glsl: Add ir_binop_mul to get_range
Thomas Helland
thomashelland90 at gmail.com
Sun Nov 16 17:51:59 PST 2014
---
src/glsl/opt_minmax.cpp | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 9d300d3..49a816e 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -344,6 +344,39 @@ get_range(ir_rvalue *rval)
high = sub(r0.high, r1.low)->constant_expression_value();
return minmax_range(low, high);
+ case ir_binop_mul:
+ r0 = get_range(expr->operands[0]);
+ r1 = get_range(expr->operands[1]);
+ // Both are positive, result is positive
+ if (r0.low && is_greater_than_or_equal_zero(r0.low) &&
+ r1.low && is_greater_than_or_equal_zero(r1.low)) {
+ low = mul(r0.low, r1.low)->constant_expression_value();
+ if (r0.high && r1.high)
+ high = mul(r0.high, r1.high)->constant_expression_value();
+ }
+ // Both are negative, result is positive
+ if (r0.high && is_less_than_or_equal_zero(r0.high) &&
+ r1.high && is_less_than_or_equal_zero(r1.high)) {
+ low = mul(r0.high, r1.high)->constant_expression_value();
+ if (r0.low && r1.low)
+ high = mul(r0.low, r1.low)->constant_expression_value();
+ }
+ // r0 positive, r1 negative, result is negative
+ if (r0.low && is_greater_than_or_equal_zero(r0.low) &&
+ r1.high && is_less_than_or_equal_zero(r1.high)) {
+ high = mul(r0.low, r1.high)->constant_expression_value();
+ if (r0.high && r1.low)
+ low = mul(r0.high, r1.low)->constant_expression_value();
+ }
+ // r0 negative, r1 positive, result is negative
+ if (r1.low && is_greater_than_or_equal_zero(r1.low) &&
+ r0.high && is_less_than_or_equal_zero(r0.high)) {
+ high = mul(r0.high, r1.low)->constant_expression_value();
+ if (r0.low && r1.high)
+ low = mul(r0.low, r1.high)->constant_expression_value();
+ }
+ return minmax_range(low, high);
+
case ir_binop_pow:
r0 = get_range(expr->operands[0]);
if (is_greater_than_or_equal_zero(r0.low))
--
2.0.3
More information about the mesa-dev
mailing list