nir/copy_prop: visit copies instead of sources
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 29 Jan 2021 17:29:32 +0000 (17:29 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Mar 2021 17:38:10 +0000 (17:38 +0000)
commitc2209d836ce97540160acf3cc607b01ecdd75c60
tree0236f172a04ce635cf255927ee55d97653dfdc30
parent41125bff4ff2e79895975f76601a6c7a18029a3d
nir/copy_prop: visit copies instead of sources

There are less copy instructions than sources, so instead of visiting each
source and rewriting it if it's uses a copy instruction, visit each copy
instruction and rewrite it's users.

Besides improving compile time, this also has a side effect of fixing a
rare situation where copy-propagation does not happen:
loop {
   a = phi ..., b
   c = vec ...
   b = mov c.y
}
It might have been the case that a phi source could not be rewritten until
the copy was visited later.

Compile-time (nir_copy_prop):
Difference at 95.0% confidence
-2613.13 +/- 15.2094
-27.4333% +/- 0.150247%
(Student's t, pooled s = 17.963)

Comple-time (overall):
Difference at 95.0% confidence
-2627.89 +/- 201.557
-2.05404% +/- 0.156221%
(Student's t, pooled s = 238.048)

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8784>
src/compiler/nir/nir_opt_copy_propagate.c