mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 00:38:48 +02:00
nir/algebraic: optimize exact f2u32(fmul(unpack_norm))
fossil-db (navi21): Totals from 16 (0.01% of 202427) affected shaders: Instrs: 17730 -> 17226 (-2.84%) CodeSize: 97500 -> 95708 (-1.84%) InvThroughput: 44437 -> 44419 (-0.04%) Copies: 1502 -> 1446 (-3.73%) VALU: 9973 -> 9525 (-4.49%) SALU: 3509 -> 3453 (-1.60%) Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40740>
This commit is contained in:
parent
f52dace6e8
commit
b30c0d8264
1 changed files with 17 additions and 0 deletions
|
|
@ -2708,6 +2708,23 @@ optimizations.extend([
|
|||
127.0))),
|
||||
'options->lower_unpack_snorm_4x8'),
|
||||
|
||||
# f2u32(fmul(unpack_*norm_*)). These are exact replacements.
|
||||
# 0x37800080 = 1.0 / 65535.0
|
||||
# 0x3b808081 = 1.0 / 255.0
|
||||
# 0x38000100 = 1.0 / 32767.0
|
||||
# 0x3c010204 = 1.0 / 127.0
|
||||
(('f2u32', ('fmul', ('fmul', ('u2f32', ('extract_u16', 'a@32', b)), 0x37800080), 65535.0)),
|
||||
('extract_u8', a, b),
|
||||
'!nir_is_rounding_mode_rtz(info->float_controls_execution_mode, 32)'),
|
||||
(('f2u32', ('fmul', ('fmul', ('u2f32', ('extract_u8', 'a@32', b)), 0x3b808081), 255.0)),
|
||||
('extract_u8', a, b)),
|
||||
(('f2u32', ('fmul', ('fmin', 1.0, ('fmax', -1.0, ('fmul', ('u2f32', ('extract_i16', 'a@32', b)), 0x38000100))), 32767.0)),
|
||||
('imax', ('extract_i16', a, b), -32767),
|
||||
'!nir_is_rounding_mode_rtz(info->float_controls_execution_mode, 32)'),
|
||||
(('f2u32', ('fmul', ('fmin', 1.0, ('fmax', -1.0, ('fmul', ('u2f32', ('extract_i8', 'a@32', b)), 0x3c010204))), 127.0)),
|
||||
('imax', ('extract_i8', a, b), -127),
|
||||
'!nir_is_rounding_mode_rtz(info->float_controls_execution_mode, 32)'),
|
||||
|
||||
(('pack_half_2x16_split', 'a@32', 'b@32'),
|
||||
('ior', ('ishl', ('u2u32', ('f2f16', b)), 16), ('u2u32', ('f2f16', a))),
|
||||
'options->lower_pack_split'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue