nir: Add algebraic optimizations for exponential/logarithmic functions.
Most of these exist in the GLSL IR algebraic pass already. However, SSA allows us to find more instances of the patterns. total NIR instructions in shared programs: 2015593 -> 2011430 (-0.21%) NIR instructions in affected programs: 124189 -> 120026 (-3.35%) helped: 604 total i965 instructions in shared programs: 6025505 -> 6018717 (-0.11%) i965 instructions in affected programs: 261295 -> 254507 (-2.60%) helped: 1295 HURT: 3 Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
@@ -96,6 +96,16 @@ optimizations = [
|
||||
(('ishr', a, 0), a),
|
||||
(('ushr', 0, a), 0),
|
||||
(('ushr', a, 0), 0),
|
||||
# Exponential/logarithmic identities
|
||||
(('fexp2', ('flog2', a)), a), # 2^lg2(a) = a
|
||||
(('fexp', ('flog', a)), a), # e^ln(a) = a
|
||||
(('flog2', ('fexp2', a)), a), # lg2(2^a) = a
|
||||
(('flog', ('fexp', a)), a), # ln(e^a) = a
|
||||
(('fexp2', ('fmul', ('flog2', a), b)), ('fpow', a, b)), # 2^(lg2(a)*b) = a^b
|
||||
(('fexp', ('fmul', ('flog', a), b)), ('fpow', a, b)), # e^(ln(a)*b) = a^b
|
||||
(('fpow', a, 1.0), a),
|
||||
(('fpow', a, 2.0), ('fmul', a, a)),
|
||||
(('fpow', 2.0, a), ('fexp2', a)),
|
||||
|
||||
# This one may not be exact
|
||||
(('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
|
||||
|
||||
Reference in New Issue
Block a user