spirv: run nir_copy_prop before nir_rematerialize_derefs_in_use_blocks_impl
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 23 Nov 2021 13:27:14 +0000 (13:27 +0000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 24 Nov 2021 15:43:51 +0000 (15:43 +0000)
commitb4251007810bc2a02d44580b04ad34ec381f891b
tree3282f39b123da673bd561d51436bf0dd64ef7a19
parent7fb6eafbc4fabd1716bc3aec451bf82c05ead28a
spirv: run nir_copy_prop before nir_rematerialize_derefs_in_use_blocks_impl

spirv_to_nir sometimes wraps derefs in vec2 or mov instructions as part of
its texture handling. These get in the way of
nir_rematerialize_derefs_in_use_blocks_impl. Running copy propagation
should get rid of the extra move instructions and get us back to intact
deref chains for everything except variable pointer use-cases.

fossil-db (Sienna Cichlid):
Totals from 6 (0.00% of 134572) affected shaders:
CodeSize: 92656 -> 93088 (+0.47%)
Instrs: 17060 -> 17138 (+0.46%)
Latency: 224408 -> 227539 (+1.40%)
InvThroughput: 37402 -> 37924 (+1.40%)
VClause: 408 -> 402 (-1.47%)
Copies: 1065 -> 1107 (+3.94%)

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5668
Fixes: 14a12b771d0 ("spirv: Rework our handling of images and samplers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13924>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_copy_propagate.c
src/compiler/spirv/vtn_cfg.c