nir/constant_folding: fold load_constant intrinsics
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 4 Sep 2019 16:03:18 +0000 (17:03 +0100)
committerRhys Perry <pendingchaos02@gmail.com>
Mon, 7 Oct 2019 18:49:53 +0000 (19:49 +0100)
commit2d78e55a8c5481ad312014edff65f5c5fad013cb
tree4cb9acf2e1a0349fc0da0081dac0cbfd20b65cc2
parentec054a67daa606b60201da144f4a3ad1a1cde451
nir/constant_folding: fold load_constant intrinsics

These can appear after loop unrolling.

v2: stylistic changes
v2: replace state->mem_ctx with state->shader
v2: add bounds checking
v3: use nir_intrinsic_range() for bounds checking
v3: fix issue where partially out-of-bounds reads are replaced with undefs
v4: fix merge conflicts during rebase
v5: split into two commits
v6: set constant_data to NULL after freeing (fixes nir_sweep()/Iris)
v7: don't remove the constant data if there are no constant loads

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com> (v6)
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_opt_constant_folding.c