From: Ian Romanick <ian.d.roman...@intel.com> For example (-x * 43) and (x * -43) should be considered common.
No shader-db changes. I'll probably drop this patch, but I wanted to send it out to show that I tried this too. Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/glsl/ir_equals.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/ir_equals.cpp b/src/glsl/ir_equals.cpp index 5f5af5b..664cbfa 100644 --- a/src/glsl/ir_equals.cpp +++ b/src/glsl/ir_equals.cpp @@ -218,6 +218,16 @@ ir_expression::equals(const ir_instruction *ir, enum ir_node_type ignore) const if (operation != other->operation) return false; + if (operation == ir_binop_mul || operation == ir_binop_div) { + /* For multiplication and division we want an even-parity of negations on + * operands. This means that 'x * y' equals '-x * -y'. + */ + return ((operands[0]->equals(other->operands[0], ignore) && + operands[1]->equals(other->operands[1], ignore)) || + (operands[0]->negative_equals(other->operands[0], ignore) && + operands[1]->negative_equals(other->operands[1], ignore))); + } + for (unsigned i = 0; i < get_num_operands(); i++) { if (!operands[i]->equals(other->operands[i], ignore)) return false; -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev