mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
nir: add option to lower slt/sge/seq/sne
In freedreno these get implemented as the matching f* instruction plus a u2f to convert the result to float 1.0/0.0. But less lines of code to just let nir_opt_algebraic handle this for us, plus opens up some small window for other opt passes to improve (ie. if some shader ended up with both a flt and slt with same src args, for example). v2: use b2f rather than u2f Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
24b78fe54e
commit
6829d76e02
2 changed files with 7 additions and 0 deletions
|
|
@ -1382,6 +1382,9 @@ typedef struct nir_shader_compiler_options {
|
|||
/** lowers fneg and ineg to fsub and isub. */
|
||||
bool lower_negate;
|
||||
|
||||
/* lower {slt,sge,seq,sne} to {flt,fge,feq,fne} + b2f: */
|
||||
bool lower_scmp;
|
||||
|
||||
/**
|
||||
* Does the driver support real 32-bit integers? (Otherwise, integers
|
||||
* are simulated by floats.)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,10 @@ optimizations = [
|
|||
(('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)),
|
||||
(('ior', ('flt', a, b), ('flt', a, c)), ('flt', a, ('fmax', b, c))),
|
||||
(('ior', ('fge', a, b), ('fge', a, c)), ('fge', a, ('fmin', b, c))),
|
||||
(('slt', a, b), ('b2f', ('flt', a, b)), 'options->lower_scmp'),
|
||||
(('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'),
|
||||
# Emulating booleans
|
||||
(('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
|
||||
(('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue