summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>2015-02-24 19:02:57 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2015-03-25 21:30:06 +0000
commit5e572b1ccee4adfba9441c793b53b7950de560c5 (patch)
tree5046ddde049a395541fd9f47458bf3b932041b3f
parent2beab3c01c7be935fc7d2f1f025373cadebdeb4d (diff)
glsl: optimize (0 cmp x + y) into (-x cmp y).
The optimization done by commit 34ec1a24d did not take it into account. Fixes: dEQP-GLES3.functional.shaders.random.all_features.fragment.20 Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Cc: "10.4 10.5" <mesa-stable@lists.freedesktop.org> (cherry picked from commit b43bbfa90ace596c8b2e0b3954a5f69924726c59)
-rw-r--r--src/glsl/opt_algebraic.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index fae58c75c0e..7f25fc41886 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -578,9 +578,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (!is_vec_zero(zero))
continue;
- return new(mem_ctx) ir_expression(ir->operation,
- add->operands[0],
- neg(add->operands[1]));
+ /* Depending of the zero position we want to optimize
+ * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y)
+ */
+ if (add_pos == 1) {
+ return new(mem_ctx) ir_expression(ir->operation,
+ neg(add->operands[0]),
+ add->operands[1]);
+ } else {
+ return new(mem_ctx) ir_expression(ir->operation,
+ add->operands[0],
+ neg(add->operands[1]));
+ }
}
break;