nir: Add an array copy optimization
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 24 Jul 2018 02:16:56 +0000 (19:16 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 24 Aug 2018 02:47:47 +0000 (21:47 -0500)
commit53072582dc9401c76bb8ef72d8f321f684fb0a15
tree2229427c9732e857225385ec7c8e1b8a6aeec87b
parenta4a9c075496c64ac333e6c0b930d8c2eb5175e8e
nir: Add an array copy optimization

This peephole optimization looks for a series of load/store_deref or
copy_deref instructions that copy an array from one variable to another
and turns it into a copy_deref that copies the entire array.  The
pattern it looks for is extremely specific but it's good enough to pick
up on the input array copies in DXVK and should also be able to pick up
the sequence generated by spirv_to_nir for a OpLoad of a large composite
followed by OpStore.  It can always be improved later if needed.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/compiler/Makefile.sources
src/compiler/nir/meson.build
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_find_array_copies.c [new file with mode: 0644]