From fe157b3a6d98ed973a0e9e65649307787fe7a535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Fri, 2 Sep 2016 09:35:49 +0300 Subject: [PATCH] glsl: additional optimization for ir_binop_div MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simply replaces div(a, b) to 1 if a equals to b. Reduces time spent with WebGL test 'temp-expressions-should-not-crash'. Time spent in bug 94477 test case goes down to ~70 secs from ~580 secs on my HSW machine. Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94477 --- src/compiler/glsl/opt_algebraic.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index f5858c8..420f5a2 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -630,6 +630,11 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) } if (is_vec_one(op_const[1])) return ir->operands[0]; + + /* simplify if div(a, b) and a equals b .. */ + if (ir->operands[0]->equals(ir->operands[1])) + return new(mem_ctx) ir_constant(1); + break; case ir_binop_dot: -- 2.7.4