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)
committerMarge Bot <emma+marge@anholt.net>
Wed, 16 Nov 2022 19:51:47 +0000 (19:51 +0000)
commit6738a7b5b4ae7a8f14fda0d39f760db4e29db186
tree1bccdf826048fe2421460102d00a0a549aebc29a
parentfe851d7759fca4c61245b142bb90dd561ae818f9
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>
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