diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index b44dad7e836..9273286691e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4016,6 +4016,9 @@ typedef struct nir_shader_compiler_options { /** lowers fquantize2f16 to alu ops. */ bool lower_fquantize2f16; + + /** Lower f2f16 to f2f16_rtz when execution mode is not rtne. */ + bool force_f2f16_rtz; } nir_shader_compiler_options; typedef struct nir_shader { diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 8a7cb3617fa..8e531b1e5b2 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3281,6 +3281,8 @@ late_optimizations += [ (('u2fmp', a), ('u2f16', a), "!options->preserve_mediump"), (('fisfinite', a), ('flt', ('fabs', a), float("inf"))), + (('f2f16', a), ('f2f16_rtz', a), "options->force_f2f16_rtz && !nir_is_rounding_mode_rtne(info->float_controls_execution_mode, 16)"), + (('fcsel', ('slt', 0, a), b, c), ('fcsel_gt', a, b, c), "options->has_fused_comp_and_csel"), (('fcsel', ('slt', a, 0), b, c), ('fcsel_gt', ('fneg', a), b, c), "options->has_fused_comp_and_csel"), (('fcsel', ('sge', a, 0), b, c), ('fcsel_ge', a, b, c), "options->has_fused_comp_and_csel"),