[Mesa-dev] [PATCH 13/22] glsl: Add ir_binop_pow to get_range
Thomas Helland
thomashelland90 at gmail.com
Sat Jan 3 11:18:18 PST 2015
V2: Replace range-setting for undefined behavior with a TODO.
Use the new IS_CONSTANT macro
--- 3< ---
Ian mentioned he was not sure what the correct behavior should be.
Optimizing based on undefined behavior is not pretty,
so remove that and instead leave a note.
---
src/glsl/opt_minmax.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index dd13800..cca18e8 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -434,6 +434,20 @@ get_range(ir_rvalue *rval)
return minmax_range(low, high);
+ case ir_binop_pow:
+ r0 = get_range(expr->operands[0]);
+
+ if (IS_CONSTANT(r0.low, >=, 0.0f))
+ low = new(mem_ctx) ir_constant(0.0f);
+
+ /* TODO: If operand(0) < 0 then the result is undefined according
+ * to the spec, so we can set the range to whatever we want.
+ * However, hardware probably follows SM2.0 or SM5.0 rules.
+ * Some apps may depend on this behavior. This needs investigation
+ */
+
+ return minmax_range(low, NULL);
+
default:
break;
}
--
2.2.1
More information about the mesa-dev
mailing list