nir: Add a pass for lowering integer division by constants

Graphics / Mesa 3D Graphics Library / Mesa - Jason Ekstrand [intel.com] - 13 December 2018 17:49 EST

It's a reasonably well-known fact in the world of compilers that integer divisions by constants can be replaced by a multiply, an add, and some shifts. This commit adds such an optimization to NIR for easiest case of udiv. Other division operations will be added in following commits. In order to provide some additional driver control, the pass takes a minimum bit size to optimize.

74492ebad9 nir: Add a pass for lowering integer division by constants
src/compiler/Makefile.sources | 1 +
src/compiler/nir/meson.build | 1 +
src/compiler/nir/nir.h | 2 +
src/compiler/nir/nir_opt_idiv_const.c | 215 ++++++++++++++++++++++++++++++++++
4 files changed, 219 insertions(+)

Upstream: cgit.freedesktop.org


  • Share