mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
nir/algebraic: Recognize open-coded bitfield_reverse in XCOM 2
The XCOM 2 shaders in my shader-db use iadd instead of ior. No fossil-db changes on any Intel platform. shader-db: All Intel platforms had similar results. (Meteor Lake shown) total instructions in shared programs: 19787210 -> 19787034 (<.01%) instructions in affected programs: 1187 -> 1011 (-14.83%) helped: 6 / HURT: 0 total cycles in shared programs: 906024436 -> 906012612 (<.01%) cycles in affected programs: 72978 -> 61154 (-16.20%) helped: 6 / HURT: 0 Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31006>
This commit is contained in:
parent
97f4250a7c
commit
057c7c9f53
1 changed files with 11 additions and 0 deletions
|
|
@ -2759,6 +2759,16 @@ optimizations += [
|
|||
(('ldexp@64', 'x', 'exp'), ldexp('x', 'exp', 64), 'options->lower_ldexp'),
|
||||
]
|
||||
|
||||
# XCOM 2 (OpenGL) open-codes bitfieldReverse()
|
||||
def bitfield_reverse_xcom2(u):
|
||||
step1 = ('iadd', ('ishl', u, 16), ('ushr', u, 16))
|
||||
step2 = ('iadd', ('iand', ('ishl', step1, 1), 0xaaaaaaaa), ('iand', ('ushr', step1, 1), 0x55555555))
|
||||
step3 = ('iadd', ('iand', ('ishl', step2, 2), 0xcccccccc), ('iand', ('ushr', step2, 2), 0x33333333))
|
||||
step4 = ('iadd', ('iand', ('ishl', step3, 4), 0xf0f0f0f0), ('iand', ('ushr', step3, 4), 0x0f0f0f0f))
|
||||
step5 = ('iadd(many-comm-expr)', ('iand', ('ishl', step4, 8), 0xff00ff00), ('iand', ('ushr', step4, 8), 0x00ff00ff))
|
||||
|
||||
return step5
|
||||
|
||||
# Unreal Engine 4 demo applications open-codes bitfieldReverse()
|
||||
def bitfield_reverse_ue4(u):
|
||||
step1 = ('ior', ('ishl', u, 16), ('ushr', u, 16))
|
||||
|
|
@ -2779,6 +2789,7 @@ def bitfield_reverse_cp2077(u):
|
|||
|
||||
return step5
|
||||
|
||||
optimizations += [(bitfield_reverse_xcom2('x@32'), ('bitfield_reverse', 'x'), '!options->lower_bitfield_reverse')]
|
||||
optimizations += [(bitfield_reverse_ue4('x@32'), ('bitfield_reverse', 'x'), '!options->lower_bitfield_reverse')]
|
||||
optimizations += [(bitfield_reverse_cp2077('x@32'), ('bitfield_reverse', 'x'), '!options->lower_bitfield_reverse')]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue