diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 3ca39ec745b..a6d488e426a 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3650,6 +3650,7 @@ for sz, mulz in itertools.product([16, 32, 64], [False, True]): fadd = 'fadd@{}(contract)'.format(sz) option = 'options->fuse_ffma{}'.format(sz) + option_with_abs = 'options->fuse_ffma{} && !options->avoid_ternary_with_fabs'.format(sz) late_optimizations.extend([ ((fadd, (fmul, a, b), c), (ffma, a, b, c), option), @@ -3658,10 +3659,10 @@ for sz, mulz in itertools.product([16, 32, 64], [False, True]): (ffma, ('fneg', a), b, c), option), ((fadd, ('fabs(is_only_used_by_fadd)', (fmul, a, b)), c), - (ffma, ('fabs', a), ('fabs', b), c), option), + (ffma, ('fabs', a), ('fabs', b), c), option_with_abs), ((fadd, ('fneg(is_only_used_by_fadd)', ('fabs', (fmul, a, b))), c), - (ffma, ('fneg', ('fabs', a)), ('fabs', b), c), option), + (ffma, ('fneg', ('fabs', a)), ('fabs', b), c), option_with_abs), ]) late_optimizations.extend([ diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 571345f3399..5a884f36b7b 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -665,6 +665,11 @@ typedef struct nir_shader_compiler_options { */ bool avoid_ternary_with_two_constants; + /* Avoid using fabs on sources to ternary operations + * r600 can't use source modifiers for these + */ + bool avoid_ternary_with_fabs; + /** Whether 8-bit ALU is supported. */ bool support_8bit_alu; diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index c1c51f755b6..85b49dd0bca 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -1166,6 +1166,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, .vectorize_tess_levels = 1, .io_options = nir_io_mediump_is_32bit, .vertex_id_zero_based = rscreen->info.gfx_level >= EVERGREEN, + .avoid_ternary_with_fabs = 1, }; rscreen->nir_options = nir_options;