nir: Add some ssa-only fast-paths for nir_src rewrite
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 30 Jan 2021 01:33:19 +0000 (19:33 -0600)
committerMarge Bot <eric+marge@anholt.net>
Tue, 2 Feb 2021 15:35:55 +0000 (15:35 +0000)
commitf064b7a42c86703b22d90240094f2ec3e8ee7797
tree623a8bace50bda2c2d29873194481af635fec9e5
parent592c17b39d949951bcf9c90138719ff7471e637e
nir: Add some ssa-only fast-paths for nir_src rewrite

Basically every pass in NIR uses nir_ssa_def_rewrite_uses which calls
nir_instr_rewrite_src which is fairly complex because it handles all
sorts of non-SSA cases.  Since we already know a priori that every
source written by nir_ssa_def_rewrite_uses is SSA, we can check new_src
once at the top of the function and cut out all that complexity.

While we're at it, we expose a new SSA-only nir_ssa_def_rewrite_uses_ssa
helper which takes an SSA def which avoids the one SSA check.  It's also
more convenient 90% of the time.

Compile time as tested by Rhys Perry <pendingchaos02@gmail.com>

    Difference at 95.0% confidence
        -797.166 +/- 418.649
        -0.566174% +/- 0.296441%
        (Student's t, pooled s = 325.459)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8790>
src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_instr_set.c
src/compiler/nir/nir_search.c