nir/algebraic: add scmp algebraic optimizations

When 'x' is the result of a scmp op:

x != 0.0 or x == 1.0: passthrough
x == 0.0 or x != 1.0: invert

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Jonathan Marek 2019-07-24 13:33:17 -04:00
parent 9be902097c
commit 97c8314c5f
1 changed files with 16 additions and 0 deletions

View File

@ -568,6 +568,22 @@ optimizations = [
(('sge', a, b), ('b2f', ('fge', a, b)), 'options->lower_scmp'),
(('seq', a, b), ('b2f', ('feq', a, b)), 'options->lower_scmp'),
(('sne', a, b), ('b2f', ('fne', a, b)), 'options->lower_scmp'),
(('seq', ('seq', a, b), 1.0), ('seq', a, b)),
(('seq', ('sne', a, b), 1.0), ('sne', a, b)),
(('seq', ('slt', a, b), 1.0), ('slt', a, b)),
(('seq', ('sge', a, b), 1.0), ('sge', a, b)),
(('sne', ('seq', a, b), 0.0), ('seq', a, b)),
(('sne', ('sne', a, b), 0.0), ('sne', a, b)),
(('sne', ('slt', a, b), 0.0), ('slt', a, b)),
(('sne', ('sge', a, b), 0.0), ('sge', a, b)),
(('seq', ('seq', a, b), 0.0), ('sne', a, b)),
(('seq', ('sne', a, b), 0.0), ('seq', a, b)),
(('seq', ('slt', a, b), 0.0), ('sge', a, b)),
(('seq', ('sge', a, b), 0.0), ('slt', a, b)),
(('sne', ('seq', a, b), 1.0), ('sne', a, b)),
(('sne', ('sne', a, b), 1.0), ('seq', a, b)),
(('sne', ('slt', a, b), 1.0), ('sge', a, b)),
(('sne', ('sge', a, b), 1.0), ('slt', a, b)),
(('fall_equal2', a, b), ('fmin', ('seq', 'a.x', 'b.x'), ('seq', 'a.y', 'b.y')), 'options->lower_vector_cmp'),
(('fall_equal3', a, b), ('seq', ('fany_nequal3', a, b), 0.0), 'options->lower_vector_cmp'),
(('fall_equal4', a, b), ('seq', ('fany_nequal4', a, b), 0.0), 'options->lower_vector_cmp'),