diff options
author | Ian Romanick <[email protected]> | 2015-03-23 12:03:56 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2015-04-14 08:35:10 -0700 |
commit | 05a1d84491eabf56564488ba0b0b0b8e91fd4309 (patch) | |
tree | 3be6e36b2070849405f31dc83381376b26c1334c /src/mesa/drivers/dri | |
parent | e0994e0f97a2078735f0b5e86cbad9f74c565c05 (diff) |
i965/fs: Always invert predicate of SEL with swapped arguments
Commit b616164 added an optimization of b2f generation of a comparison.
It also included an extra optimization of one of the comparison values
is a constant of zero. The trick was that some value was known to be
zero, so that value could be used in the SEL instruction instead of
potentially loading 0.0 into a register.
This change switched the order of the arguments to the SEL, and, for
some unknown reason, I thought that the predicate should therefore
only be inverted for the == case. Clearly, it should always be
inverted.
Fixes piglit fs-notEqual-of-expression.shader_test and
fs-equal-of-expression.shader_test.
v2: Don't do the "register already has zero" optimization for the '== 0'
case. In that case, the register does not have zero when we want to
produce a zero result.
Signed-off-by: Ian Romanick <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89722
Reviewed-by: Kenneth Graunke <[email protected]> [v1]
Tested-by: Lu Hua <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 06337c9051a..0049b2d6775 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -502,15 +502,15 @@ fs_visitor::try_emit_b2f_of_comparison(ir_expression *ir) * and(16) g4<1>D g2<8,8,1>D 1D * and(16) m6<1>D -g4<8,8,1>D 0x3f800000UD * - * When the comparison is either == 0.0 or != 0.0 using the knowledge that - * the true (or false) case already results in zero would allow better code - * generation by possibly avoiding a load-immediate instruction. + * When the comparison is != 0.0 using the knowledge that the false case + * already results in zero would allow better code generation by possibly + * avoiding a load-immediate instruction. */ ir_expression *cmp = ir->operands[0]->as_expression(); if (cmp == NULL) return false; - if (cmp->operation == ir_binop_equal || cmp->operation == ir_binop_nequal) { + if (cmp->operation == ir_binop_nequal) { for (unsigned i = 0; i < 2; i++) { ir_constant *c = cmp->operands[i]->as_constant(); if (c == NULL || !c->is_zero()) @@ -538,7 +538,7 @@ fs_visitor::try_emit_b2f_of_comparison(ir_expression *ir) fs_inst *inst = emit(SEL(this->result, op[i ^ 1], fs_reg(1.0f))); inst->predicate = BRW_PREDICATE_NORMAL; - inst->predicate_inverse = cmp->operation == ir_binop_equal; + inst->predicate_inverse = true; return true; } } |