nir/opt_algebraic: optimize fmax(-fmin(b, a), b) -> fmax(b, -a)
Found with Cyberpunk 2077. fossils-db (GFX10.3): Totals from 128 (2.34% of 5465) affected shaders: CodeSize: 769720 -> 767656 (-0.27%); split: -0.27%, +0.00% Instrs: 145748 -> 145229 (-0.36%) Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11604>
This commit is contained in:
committed by
Marge Bot
parent
0cddfba328
commit
07cd30ca29
@@ -652,6 +652,11 @@ optimizations.extend([
|
||||
# fmin(0.0, b)) while the right one is "b", so this optimization is inexact.
|
||||
(('~fmin', ('fsat', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))),
|
||||
|
||||
# max(-min(b, a), b) -> max(b, -a)
|
||||
# min(-max(b, a), b) -> min(-b, -a)
|
||||
(('fmax', ('fneg', ('fmin', b, a)), b), ('fmax', b, ('fneg', a))),
|
||||
(('fmin', ('fneg', ('fmax', b, a)), b), ('fmin', ('fneg', b), ('fneg', a))),
|
||||
|
||||
# If a in [0,b] then b-a is also in [0,b]. Since b in [0,1], max(b-a, 0) =
|
||||
# fsat(b-a).
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user