Skip to content

nir: Add an integer divide by constant optimization

Faith Ekstrand requested to merge gfxstrand/mesa:review/nir-intdiv-const into master

It's reasonably well-known that you can replace an unsigned integer division by a constant with a sequence of multiply (by constant), adds, and shifts. This little series implements such an optimization for NIR. As can be seen from the last patch, there really aren't that many shaders affected by this and most of them are because we are finally optimizing signed integer division by powers of two. However, it seems like a good thing to have in our pockets none-the-less, especially for 64-bit where divisions turn into manually implementing the division algorithm.

Merge request reports