aco: Flip s_cbranch / s_cselect to optimize out an s_not if possible.
authorTimur Kristóf <timur.kristof@gmail.com>
Tue, 19 Nov 2019 12:29:54 +0000 (13:29 +0100)
committerTimur Kristóf <timur.kristof@gmail.com>
Tue, 14 Jan 2020 20:21:06 +0000 (21:21 +0100)
commitdfaa3c0af69ab035cb825943b1cee0f60272010e
tree55f236d11abca12e217d58ac517afff28871b716
parentc0f82165a7a3e572fb3c08c8afbb6755be2b8b42
aco: Flip s_cbranch / s_cselect to optimize out an s_not if possible.

When possible, get rid of an s_not when all it does is invert the SCC,
and its successor s_cbranch / s_cselect can be inverted instead.

Also modify some parts of instruction_selection to take advantage of
this feature.

Example:
s2: %3900,  s1: %3899:scc = s_andn2_b64 %0:exec, %406
s2: %3902 = s_cselect_b64 -1, 0, %3900:scc
s2: %407,  s1: %3903:scc = s_not_b64 %3902
s2: %3906,  s1: %3905:scc = s_and_b64 %407, %0:exec
p_cbranch_z %3905:scc
Can now be optimized to:
s2: %3900,  s1: %3899:scc = s_andn2_b64 %0:exec, %406
p_cbranch_nz %3900:scc

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/amd/compiler/aco_instruction_selection.cpp
src/amd/compiler/aco_optimizer.cpp