nir/algebraic: Optimize some u2f of bfi
v2: Fix a copy-and-paste bug s/('find_lsb', a)/a/ in the patterns. See
piglit!819.
DG2, Tiger Lake, Ice Lake, Skylake, and Broadwell had similar results (Ice Lake shown)
total instructions in shared programs: 20570063 -> 20570033 (<.01%)
instructions in affected programs: 452 -> 422 (-6.64%)
helped: 30 / HURT: 0
total cycles in shared programs: 902118723 -> 902118781 (<.01%)
cycles in affected programs: 1762 -> 1820 (3.29%)
helped: 0 / HURT: 29
DG2, Tiger Lake, Ice Lake, and Skylake had similar results (Ice Lake shown)
Totals:
Instrs: 152819969 -> 152819500 (-0.00%)
Cycles: 15014628652 -> 15014627187 (-0.00%); split: -0.00%, +0.00%
Totals from 469 (0.07% of 662497) affected shaders:
Instrs: 7644 -> 7175 (-6.14%)
Cycles: 31787 -> 30322 (-4.61%); split: -4.90%, +0.29%
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19968>
This commit is contained in:
@@ -1385,6 +1385,15 @@ optimizations.extend([
|
||||
(('uror@16', a, b), ('ior', ('ushr', a, b), ('ishl', a, ('isub', 16, b))), 'options->lower_rotate'),
|
||||
(('uror@32', a, b), ('ior', ('ushr', a, b), ('ishl', a, ('isub', 32, b))), 'options->lower_rotate'),
|
||||
(('uror@64', a, b), ('ior', ('ushr', a, b), ('ishl', a, ('isub', 64, b))), 'options->lower_rotate'),
|
||||
|
||||
# Because 'a' is a positive power of two, the result of the bfi is either 0
|
||||
# or 'a' depending on whether or not 'b' is odd. Use 'b&1' for the zero
|
||||
# value to help platforms that can't have two constants in a bcsel.
|
||||
(('u2f32', ('bfi', '#a(is_pos_power_of_two)', b, 0)),
|
||||
('bcsel', ('ieq', ('iand', b, 1), 0), ('iand', b, 1), ('u2f', a))),
|
||||
(('u2f', ('bfi', '#a(is_pos_power_of_two)', b, 0)),
|
||||
('bcsel', ('ieq', ('iand', b, 1), 0), 0, ('u2f', a))),
|
||||
|
||||
# Exponential/logarithmic identities
|
||||
(('~fexp2', ('flog2', a)), a), # 2^lg2(a) = a
|
||||
(('~flog2', ('fexp2', a)), a), # lg2(2^a) = a
|
||||
|
||||
Reference in New Issue
Block a user