nir/opt_algebraic: Allow two-step lowering of ftrunc@64 to use ffract@64

If ftrunc@64 is lowered by nir_lower_doubles it is turned into a
comparable long series of 32 bit operations. If the hardware
supports ffract@64 then nir_opt_algebraic can first lower ftrunc@64
to use some combinations with ffloor@64. They can then be turned
into a combination of fsub@64 and ffract@64 resulting in less
all-over instructions.

Fixes: 5218cff34b
   nir/algebraic: avoid double lowering of some fp64 operations

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29281>
(cherry picked from commit f19f1ec17b)
This commit is contained in:
Gert Wollny 2024-05-04 11:38:30 +02:00 committed by Eric Engestrom
parent 4f57a4da87
commit f8b6a9253a
2 changed files with 2 additions and 2 deletions

View file

@ -194,7 +194,7 @@
"description": "nir/opt_algebraic: Allow two-step lowering of ftrunc@64 to use ffract@64",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "5218cff34b34cec4819a382c500934fd9d991a60",
"notes": null

View file

@ -432,7 +432,7 @@ optimizations.extend([
(('ftrunc@16', a), ('bcsel', ('flt', a, 0.0), ('fneg', ('ffloor', ('fabs', a))), ('ffloor', ('fabs', a))), 'options->lower_ftrunc'),
(('ftrunc@32', a), ('bcsel', ('flt', a, 0.0), ('fneg', ('ffloor', ('fabs', a))), ('ffloor', ('fabs', a))), 'options->lower_ftrunc'),
(('ftrunc@64', a), ('bcsel', ('flt', a, 0.0), ('fneg', ('ffloor', ('fabs', a))), ('ffloor', ('fabs', a))),
'(options->lower_ftrunc || (options->lower_doubles_options & nir_lower_dtrunc)) && !(options->lower_doubles_options & nir_lower_dfloor)'),
'(options->lower_ftrunc || (options->lower_doubles_options & nir_lower_dtrunc)) && (!(options->lower_doubles_options & nir_lower_dfloor) || !(options->lower_doubles_options & nir_lower_dfract))'),
(('ffloor@16', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),
(('ffloor@32', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'),