i965/fs: Don't double-accept operands of logical and/or/xor operations.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 23 Sep 2013 20:37:00 +0000 (13:37 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 26 Sep 2013 23:55:18 +0000 (16:55 -0700)
commitaac75f877da1d106f6fd7bbd238d1d1d35a0c8e8
treea212f3b66ca6aed8cdfceeede761215e39f2b4ff
parente5c49bc25b07b76dbcf577186484ab271114c48a
i965/fs: Don't double-accept operands of logical and/or/xor operations.

If the argument to emit_bool_to_cond_code() is an ir_expression, we
loop over the operands, calling accept() on each of them, which
generates assembly code to compute that subexpression.  We then emit
one or two final instruction that perform the top-level operation on
those operands.

If it's not an expression (say, a boolean-valued variable), we simply
call accept() on the whole value.

In commit 80ecb8f1 (i965/fs: Avoid generating extra AND instructions on
bool logic ops), Eric made logic operations jump out of the expression
path to the non-expression path.

Unfortunately, this meant that we would first accept() the two operands,
skip generating any code that used them, then accept() the whole
expression, generating code for the operands a second time.

Dead code elimination would always remove the first set of redundant
operand assembly, since nothing actually used them.  But we shouldn't
generate it in the first place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp