aco: optimize boolean phis with uniform selections
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 9 Jan 2020 16:51:34 +0000 (16:51 +0000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 10 Jul 2020 22:36:14 +0000 (22:36 +0000)
commit9a089baff1af757b1c0f033f4bb16cb2c8864271
tree71c50d58448c9aa13a3faf4e01c1ac494af6eeca
parentf622e80494f209a0c51cc804bb900eefe8f2fdaa
aco: optimize boolean phis with uniform selections

Even though the boolean can be divergent, the control flow can be (at
least partially) uniform. For example, we don't have to create any
s_andn2_b64/s_and_b64/s_or_b64 instructions with this code:
a = ...
loop {
    b = bool_phi a, c
    if (uniform)
        break
    c = ...
}
d = phi c

fossil-db (Navi):
Totals from 5506 (4.05% of 135946) affected shaders:
SGPRs: 605720 -> 604024 (-0.28%)
SpillSGPRs: 52025 -> 51733 (-0.56%)
CodeSize: 65221188 -> 64957808 (-0.40%); split: -0.41%, +0.00%
Instrs: 12637881 -> 12584610 (-0.42%); split: -0.42%, +0.00%

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3388>
src/amd/compiler/aco_lower_phis.cpp