Skip to content

NIR: Improve handling of opt_algebraic search patterns that have many commutative expressions

After having a problem with a nir_opt_algebraic pattern last week followed by a bit of discussion on mesa-dev with @cwabbott0, I discovered that it's possible to exceed the maximum number of commutative expressions that nir_replace_instr can handle, and, when you do, you have no clue that you've exceeded the limit (that you may not have known existed).

This series does three things.

  1. Notify you when you exceed the limit.
  2. Make it harder to exceed the limit by marking some things that commutative as non-commutative.
  3. Increases the limit from 4 to 8.

I had another patch that skips re-trying an expression like a+a when it failed to match the first time. I had hoped this might improve performance slightly. It didn't make any difference on a shader-db run on the 36-core system, so I dropped it. That patch is still available.

Edited by Ian Romanick

Merge request reports

Loading