nir: optimize i2f(f2i(fsign))
authorGeorg Lehmann <dadschoorse@gmail.com>
Sat, 18 Mar 2023 13:32:27 +0000 (14:32 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 22 Mar 2023 05:34:55 +0000 (05:34 +0000)
Foz-DB Navi10:
Totals from 3013 (2.23% of 134906) affected shaders:
VGPRs: 138068 -> 136964 (-0.80%); split: -0.80%, +0.00%
CodeSize: 10476416 -> 10391800 (-0.81%)
MaxWaves: 79118 -> 80088 (+1.23%)
Instrs: 1963227 -> 1945003 (-0.93%)
Latency: 24734883 -> 24649279 (-0.35%); split: -0.39%, +0.05%
InvThroughput: 6366777 -> 6334735 (-0.50%); split: -0.50%, +0.00%
VClause: 36845 -> 36882 (+0.10%); split: -0.26%, +0.36%
SClause: 59249 -> 59273 (+0.04%); split: -0.25%, +0.29%
Copies: 108570 -> 108501 (-0.06%); split: -0.19%, +0.13%
PreSGPRs: 105371 -> 105862 (+0.47%)
PreVGPRs: 117675 -> 116625 (-0.89%); split: -0.89%, +0.00%

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22003>

src/compiler/nir/nir_opt_algebraic.py

index 311b4ce..fc5d318 100644 (file)
@@ -987,6 +987,9 @@ for s in [16, 32, 64]:
        # float? -> float? -> intS ==> float? -> intS
        (('~f2u{}'.format(s), ('f2f', a)), ('f2u{}'.format(s), a)),
        (('~f2i{}'.format(s), ('f2f', a)), ('f2i{}'.format(s), a)),
+
+       # HLSL's sign function returns an integer
+       (('i2f{}'.format(s), ('f2i', ('fsign', 'a@{}'.format(s)))), ('fsign', a)),
     ])
 
     for B in [32, 64]: