r300: be more careful with presubtract and non-native swizzles
authorPavel Ondračka <pavel.ondracka@gmail.com>
Tue, 15 Nov 2022 15:43:25 +0000 (16:43 +0100)
committerEric Engestrom <eric@engestrom.ch>
Thu, 29 Dec 2022 19:25:29 +0000 (19:25 +0000)
commitedb0e10b5ab6a2b453a8a6debdf4c00ecf7fc297
tree3ca6c90364c06a1d716b179f849003ff1ef1ed66
parent49d8af74ed5d6bbf1640cf57fc126a92248b7124
r300: be more careful with presubtract and non-native swizzles

The problematic scenario is when we have the same source used by both
normal and presubtract argument. We check that case currently and count
the source only once. However if one of the arguments uses a non-native
swizzle, we have to rewrite it later and the source changes. Therefore
we end with too many sources and fail later during pair translation.

Example:
ADD temp[21].xy, temp[20].xy__, temp[17].xy__;
MAD temp[22].xy, temp[17].zw__, temp[11].xy__, temp[21].xy__;

will get converted to

MAD temp[22].xy, temp[17].zw__, temp[11].xy__, (temp[17] + temp[20]).xy__;

however after dataflow swizzles pass we end with

MOV temp[3].x, temp[17].z___;
MOV temp[3].y, temp[17]._w__;
MAD temp[22].xy, temp[3].xy__, temp[11].xy__, (temp[17] + temp[20]).xy__;

Just skip the "don't count the same source twice" optimization when a
non-native swizzle is used to fix 2 dEQP atan2 tests.

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Filip Gawin <filip@gawin.net>
Tested-by: Filip Gawin <filip@gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19764>
(cherry picked from commit 6738a7b5b4ae7a8f14fda0d39f760db4e29db186)
.pick_status.json
src/gallium/drivers/r300/ci/r300-r480-fails.txt
src/gallium/drivers/r300/compiler/radeon_compiler_util.c
src/gallium/drivers/r300/compiler/radeon_compiler_util.h
src/gallium/drivers/r300/compiler/radeon_dataflow.c
src/gallium/drivers/r300/compiler/radeon_dataflow.h
src/gallium/drivers/r300/compiler/radeon_optimize.c
src/gallium/drivers/r300/compiler/tests/radeon_compiler_util_tests.c