diff options
author | Matt Turner <[email protected]> | 2015-02-27 10:59:17 -0800 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-03-07 18:23:15 +0000 |
commit | 31fcb21ef523434a254c0bbff515345c2c6d8152 (patch) | |
tree | abfbd754f05e9cee3d55fb4f5871bb8b13e4a61f /src | |
parent | 0cd8e357e323f39603bfb178108d94f83d6a3c37 (diff) |
i965: Avoid applying negate to wrong MAD source.
For some given GLSL IR like (+ (neg x) (* 1.2 x)), the try_emit_mad
function would see that one of the +'s sources was a negate expression
and set mul_negate = true without confirming that it was actually a
multiply.
Cc: 10.5 <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89315
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89095
Reviewed-by: Ian Romanick <[email protected]>
(cherry picked from commit d528907fd2950c7bb968fff66dd79863cd128890)
[Emil Velikov: drop the changes in brw_vec4_visitor.cpp]
Signed-off-by: Emil Velikov <[email protected]>
Conflicts:
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 6cddcf5e7e9..d8e10dfa538 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -428,21 +428,16 @@ fs_visitor::try_emit_mad(ir_expression *ir) if (ir->type != glsl_type::float_type) return false; - ir_rvalue *nonmul = ir->operands[1]; - ir_expression *mul = ir->operands[0]->as_expression(); + ir_rvalue *nonmul; + ir_expression *mul; + bool mul_negate, mul_abs; - bool mul_negate = false, mul_abs = false; - if (mul && mul->operation == ir_unop_abs) { - mul = mul->operands[0]->as_expression(); - mul_abs = true; - } else if (mul && mul->operation == ir_unop_neg) { - mul = mul->operands[0]->as_expression(); - mul_negate = true; - } + for (int i = 0; i < 2; i++) { + mul_negate = false; + mul_abs = false; - if (!mul || mul->operation != ir_binop_mul) { - nonmul = ir->operands[0]; - mul = ir->operands[1]->as_expression(); + mul = ir->operands[i]->as_expression(); + nonmul = ir->operands[1 - i]; if (mul && mul->operation == ir_unop_abs) { mul = mul->operands[0]->as_expression(); @@ -452,10 +447,13 @@ fs_visitor::try_emit_mad(ir_expression *ir) mul_negate = true; } - if (!mul || mul->operation != ir_binop_mul) - return false; + if (mul && mul->operation == ir_binop_mul) + break; } + if (!mul || mul->operation != ir_binop_mul) + return false; + if (nonmul->as_constant() || mul->operands[0]->as_constant() || mul->operands[1]->as_constant()) |