[Mesa-dev] [PATCH 5/6] glsl: Optimize various cases of fma (aka MAD).
Eric Anholt
eric at anholt.net
Sun Jan 19 23:18:37 PST 2014
---
src/glsl/opt_algebraic.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 4a96a55..7fbc32e 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -502,6 +502,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])) {
--
1.8.5.2
More information about the mesa-dev
mailing list