mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 02:20:11 +01:00
nir/opt_algebraic: optimize f2i32(fround_even(x)) to f2i32_rtne(x)
Add late optimization to fuse f2i32 and fround_even operations into a single f2i32_rtne instruction when the intermediate fround_even result is only used once. This eliminates redundant rounding since f2i32_rtne performs round-to-nearest-even conversion directly. Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Tested-by: Simon Perretta <simon.perretta@imgtec.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37426>
This commit is contained in:
parent
0f320b7a1d
commit
a7d2570296
2 changed files with 7 additions and 0 deletions
|
|
@ -4024,6 +4024,10 @@ for s in [16, 32, 64]:
|
|||
(('bcsel@{}'.format(s), ('ine', 0, 'a@{}'.format(s)), 'b@{}'.format(s), 'c@{}'.format(s)), ('icsel_eqz', a, c, b), "options->has_icsel_eqz{} && !options->no_integers".format(s)),
|
||||
])
|
||||
|
||||
late_optimizations += [
|
||||
(('f2i32', ('fround_even(is_used_once)', 'a@32')), ('f2i32_rtne', a), 'options->has_f2i32_rtne'),
|
||||
]
|
||||
|
||||
distribute_src_mods = [
|
||||
# Try to remove some spurious negations rather than pushing them down.
|
||||
(('fmul', ('fneg', a), ('fneg', b)), ('fmul', a, b)),
|
||||
|
|
|
|||
|
|
@ -646,6 +646,9 @@ typedef struct nir_shader_compiler_options {
|
|||
/** Backend supports load_global_bounded intrinsics. */
|
||||
bool has_load_global_bounded;
|
||||
|
||||
/** Backend supports f2i32_rtne opcode. */
|
||||
bool has_f2i32_rtne;
|
||||
|
||||
/**
|
||||
* Is this the Intel vec4 backend?
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue