The spec states that log / log2 of x <= 0 is undefined. Just set the range to 0 if this is the case.
Also set the range according to how we are oriented around one, as this causes us to shift from positive to negative values. V2: Utilize the new IS_CONSTANT() macro Put in alphabetic order --- src/glsl/opt_minmax.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp index 5515f51..0901c95 100644 --- a/src/glsl/opt_minmax.cpp +++ b/src/glsl/opt_minmax.cpp @@ -356,6 +356,23 @@ get_range(ir_rvalue *rval) return minmax_range(new(mem_ctx) ir_constant(0.0f), NULL); + case ir_unop_log: + case ir_unop_log2: + r0 = get_range(expr->operands[0]); + + // Result is undefined, so we can set the range to whatever + if (IS_CONSTANT(r0.high, <=, 0.0f)) + return minmax_range(new(mem_ctx) ir_constant(0.0f), + new(mem_ctx) ir_constant(0.0f)); + + if (IS_CONSTANT(r0.low, >=, 1.0f)) + low = new(mem_ctx) ir_constant(0.0f); + + if (IS_CONSTANT(r0.high, <=, 1.0f)) + high = new(mem_ctx) ir_constant(0.0f); + + return minmax_range(low, high); + case ir_unop_exp: case ir_unop_exp2: case ir_unop_sqrt: -- 2.2.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev