Module: Mesa
Branch: main
Commit: ddcf29202d012e3b2ea715bf1f0d0f7e0c91be7c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ddcf29202d012e3b2ea715bf1f0d0f7e0c91be7c

Author: Pavel Ondračka <pavel.ondra...@gmail.com>
Date:   Thu Sep 21 21:53:04 2023 +0200

r300: add some more early bool lowering

We can't call nir_lower_bool_to_float too early, because some other
passes like nir_opt_peephole_select will blow up, but we can still do
some selected parts to enable some optimiazions at a later point
(like fcsel(a,b,0) into fmul), etc.

No change in shader-db with RV370 or RV530 at this point.

Reviewed-by: Filip Gawin <filip.ga...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26816>

---

 src/gallium/drivers/r300/compiler/r300_nir_algebraic.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py 
b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
index c01b43beefc..361549bd419 100644
--- a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
+++ b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
@@ -126,6 +126,14 @@ def main():
         (('bcsel@32(is_only_used_as_float)', ignore_exact('fge', 'a@32', 
'b@32'), c, d),
              ('fadd', ('fmul', c, ('sge', a, b)), ('fsub', d, ('fmul', d, 
('sge', a, b)))),
           "!options->has_fused_comp_and_csel"),
+        (('bcsel@32(is_only_used_as_float)', ('feq', 'a@32', 'b@32'), c, d),
+             ('fcsel', ('seq', a, b), c, d), 
"options->has_fused_comp_and_csel"),
+        (('bcsel@32(is_only_used_as_float)', ('fneu', 'a@32', 'b@32'), c, d),
+             ('fcsel', ('sne', a, b), c, d), 
"options->has_fused_comp_and_csel"),
+        (('bcsel@32(is_only_used_as_float)', ('flt', 'a@32', 'b@32'), c, d),
+             ('fcsel', ('slt', a, b), c, d), 
"options->has_fused_comp_and_csel"),
+        (('bcsel@32(is_only_used_as_float)', ('fge', 'a@32', 'b@32'), c, d),
+             ('fcsel', ('sge', a, b), c, d), 
"options->has_fused_comp_and_csel"),
 ]
 
     with open(args.output, 'w') as f:

Reply via email to