diff options
author | Eric Anholt <[email protected]> | 2014-01-18 11:06:16 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-02-07 12:46:48 -0800 |
commit | de796b0ef09f05ca3f8a568ed07293e28ae697b0 (patch) | |
tree | 3ca9b36fb028691691cd480b7a6df552c5c161ed /src/glsl/opt_algebraic.cpp | |
parent | 44577c48573acdbc8a708e6613f367507e9eafc5 (diff) |
glsl: Optimize various cases of fma (aka MAD).
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 392051f4f05..7863fe8f9cf 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -547,6 +547,19 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) break; + case ir_triop_fma: + /* Operands are op0 * op1 + op2. */ + if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { + return ir->operands[2]; + } else if (is_vec_zero(op_const[2])) { + return mul(ir->operands[0], ir->operands[1]); + } else if (is_vec_one(op_const[0])) { + return add(ir->operands[1], ir->operands[2]); + } else if (is_vec_one(op_const[1])) { + return add(ir->operands[0], ir->operands[2]); + } + break; + case ir_triop_lrp: /* Operands are (x, y, a). */ if (is_vec_zero(op_const[2])) { |