nir: don't turn ieq/ine into inot if used by an if

Otherwise we will end up with an extra instruction to compare the
result of the inot.

On BDW:

total instructions in shared programs: 13060620 -> 13060481 (-0.00%)
instructions in affected programs: 103379 -> 103240 (-0.13%)
helped: 127
HURT: 0

total cycles in shared programs: 256590950 -> 256587408 (-0.00%)
cycles in affected programs: 11324730 -> 11321188 (-0.03%)
helped: 114
HURT: 21

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Timothy Arceri
2017-01-08 23:52:59 +11:00
parent 7acc865226
commit de8b03f5fb
2 changed files with 8 additions and 2 deletions

View File

@@ -267,9 +267,9 @@ optimizations = [
(('~frcp', ('frsq', a)), ('fsqrt', a), '!options->lower_fsqrt'), (('~frcp', ('frsq', a)), ('fsqrt', a), '!options->lower_fsqrt'),
# Boolean simplifications # Boolean simplifications
(('ieq', 'a@bool', True), a), (('ieq', 'a@bool', True), a),
(('ine', 'a@bool', True), ('inot', a)), (('ine(is_not_used_by_if)', 'a@bool', True), ('inot', a)),
(('ine', 'a@bool', False), a), (('ine', 'a@bool', False), a),
(('ieq', 'a@bool', False), ('inot', 'a')), (('ieq(is_not_used_by_if)', 'a@bool', False), ('inot', 'a')),
(('bcsel', a, True, False), a), (('bcsel', a, True, False), a),
(('bcsel', a, False, True), ('inot', a)), (('bcsel', a, False, True), ('inot', a)),
(('bcsel@32', a, 1.0, 0.0), ('b2f', a)), (('bcsel@32', a, 1.0, 0.0), ('b2f', a)),

View File

@@ -130,4 +130,10 @@ is_used_more_than_once(nir_alu_instr *instr)
return true; return true;
} }
static inline bool
is_not_used_by_if(nir_alu_instr *instr)
{
return list_empty(&instr->dest.dest.ssa.if_uses);
}
#endif /* _NIR_SEARCH_ */ #endif /* _NIR_SEARCH_ */