nir: Add a pass for lowering integer division by constants

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.

Reviewed-by: Ian Romanick ian.d.romanick@intel.com
This commit is contained in:
Jason Ekstrand
2017-12-28 13:06:28 -08:00
committed by Jason Ekstrand
parent 090e282407
commit 74492ebad9
4 changed files with 219 additions and 0 deletions

View File

@@ -3174,6 +3174,8 @@ bool nir_opt_find_array_copies(nir_shader *shader);
bool nir_opt_gcm(nir_shader *shader, bool value_number);
bool nir_opt_idiv_const(nir_shader *shader, unsigned min_bit_size);
bool nir_opt_if(nir_shader *shader);
bool nir_opt_intrinsics(nir_shader *shader);