diff options
author | Matt Turner <[email protected]> | 2014-09-07 00:41:41 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-09-27 12:18:37 -0700 |
commit | 5ccdc23a86978628449ace0058cd3697020b0c94 (patch) | |
tree | 9ed677bba3e223e8ff6d7680bb6e5f10c05dae27 /src | |
parent | e9aee2572a56b24d69dd1e01c1a1db3608dd2bc9 (diff) |
glsl: Recognize open-coded pow(x, y).
pow(x, y) is equivalent to exp(log(x) * y).
instructions in affected programs: 578 -> 458 (-20.76%)
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 447618f9ef9..0cdb8ecfc0a 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -357,6 +357,20 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (op_expr[0]->operation == ir_unop_log2) { return op_expr[0]->operands[0]; } + + if (!options->EmitNoPow && op_expr[0]->operation == ir_binop_mul) { + for (int log2_pos = 0; log2_pos < 2; log2_pos++) { + ir_expression *log2_expr = + op_expr[0]->operands[log2_pos]->as_expression(); + + if (log2_expr && log2_expr->operation == ir_unop_log2) { + return new(mem_ctx) ir_expression(ir_binop_pow, + ir->type, + log2_expr->operands[0], + op_expr[0]->operands[1 - log2_pos]); + } + } + } break; case ir_unop_log2: |