diff --git a/src/gallium/drivers/r300/compiler/nir_to_rc.c b/src/gallium/drivers/r300/compiler/nir_to_rc.c index 97a712036e1..bfc65970429 100644 --- a/src/gallium/drivers/r300/compiler/nir_to_rc.c +++ b/src/gallium/drivers/r300/compiler/nir_to_rc.c @@ -2466,7 +2466,7 @@ const void *nir_to_rc_options(struct nir_shader *s, NIR_PASS_V(s, r300_nir_lower_fcsel_r300); NIR_PASS_V(s, r300_nir_lower_flrp); } - NIR_PASS_V(s, r300_nir_clean_double_fneg); + NIR_PASS_V(s, r300_nir_opt_algebraic_late); NIR_PASS_V(s, nir_opt_dce); nir_move_options move_all = diff --git a/src/gallium/drivers/r300/compiler/r300_nir.h b/src/gallium/drivers/r300/compiler/r300_nir.h index 83a28459136..2a49864af96 100644 --- a/src/gallium/drivers/r300/compiler/r300_nir.h +++ b/src/gallium/drivers/r300/compiler/r300_nir.h @@ -79,7 +79,7 @@ extern bool r300_nir_lower_bool_to_float(struct nir_shader *shader); extern bool r300_nir_prepare_presubtract(struct nir_shader *shader); -extern bool r300_nir_clean_double_fneg(struct nir_shader *shader); +extern bool r300_nir_opt_algebraic_late(struct nir_shader *shader); extern bool r300_nir_post_integer_lowering(struct nir_shader *shader); diff --git a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py index cf13f30bef1..fc6a8519429 100644 --- a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py +++ b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py @@ -87,11 +87,12 @@ for multiplier in [2.0, 4.0, 8.0, 16.0, 0.5, 0.25, 0.125, 0.0625]: (('fmul', a, ('fmul(is_used_once)', 'b(is_ubo_or_input)', multiplier)), ('fmul', multiplier, ('fmul', a, b))), ]) -# Previous prepare_presubtract pass can sometimes produce double fneg patterns. -# The backend copy propagate could handle it, but the nir to tgsi translation -# does not and blows up. Just run a simple pass to clean it up. -r300_nir_clean_double_fneg = [ - (('fneg', ('fneg', a)), a) +r300_nir_opt_algebraic_late = [ + # Previous prepare_presubtract pass can sometimes produce double fneg patterns. + # The backend copy propagate could handle it, but the nir to tgsi translation + # does not and blows up. Clean this up. + (('fneg', ('fneg', a)), a), + (('fabs', ('fneg', a)), ('fabs', a)), ] # This is very late flrp lowering to clean up after bcsel->fcsel->flrp. @@ -167,8 +168,8 @@ def main(): f.write(nir_algebraic.AlgebraicPass("r300_nir_prepare_presubtract", r300_nir_prepare_presubtract).render()) - f.write(nir_algebraic.AlgebraicPass("r300_nir_clean_double_fneg", - r300_nir_clean_double_fneg).render()) + f.write(nir_algebraic.AlgebraicPass("r300_nir_opt_algebraic_late", + r300_nir_opt_algebraic_late).render()) f.write(nir_algebraic.AlgebraicPass("r300_nir_post_integer_lowering", r300_nir_post_integer_lowering).render())