nir: Optimize integer division and modulus with 1
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 19 Oct 2016 15:53:10 +0000 (08:53 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 19 Oct 2016 21:25:10 +0000 (14:25 -0700)
commit4d35683d91e3d61bf14b76d801bf6ae17237e162
tree38228799ee9e32e268947ce31bc99cbf7329a0ca
parentbaed5eab82262bf9b76f5e237ecf21605360d0e3
nir: Optimize integer division and modulus with 1

The previous power-of-two rules didn't catch idiv (because i965 doesn't
set lower_idiv) and imod cases.  The udiv and umod cases should have
been caught, but I included them for orthogonality.

This fixes silly code observed from compute shaders with local_size_[xy]
= 1.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98299
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_opt_algebraic.py