r300: allow constant swizzles with inline constant
authorPavel Ondračka <pavel.ondracka@gmail.com>
Thu, 14 Jul 2022 16:35:56 +0000 (18:35 +0200)
committerPavel Ondračka <pavel.ondracka@gmail.com>
Sun, 21 Aug 2022 07:49:08 +0000 (09:49 +0200)
commitaeae7b812cc05328268047c8d4cb7cfdea3bcf38
tree99114f8013eb01f13b8bf21750fe649976eee715
parent7b60414494bbc973fe65a565aec255c0cea99884
r300: allow constant swizzles with inline constant

This will prevent a regression in the number of inlined constants in
a later commit. Constructs like 4.000000 (0x48).w110 works just fine.

There is a small behavioral change. We would previously allow positive
and negative same-value contants to be produced, e.g.,
4.000000 (0x48).w-w__ and this would be later split into some extra
movs in the dataflow swizzle pass. We now explicitly check that the
final swizzle is valid while inlining. So there is a minor decrease
in inlined constants and in the total instructions.

total lits in shared programs: 4328 -> 4194 (-3.10%)
lits in affected programs: 554 -> 420 (-24.19%)
total instructions in shared programs: 155488 -> 155361 (-0.08%)
instructions in affected programs: 5707 -> 5580 (-2.23%)

Additonally, a fix for pair translation is needed since the constant
inlining can now produce swizzles like this: 4.000000 (0x48).w-0-0-_
so we have to teach pair translation to also ignore the sign for zero
swizzle.

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Filip Gawin <filip@gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17560>
src/gallium/drivers/r300/compiler/radeon_inline_literals.c
src/gallium/drivers/r300/compiler/radeon_pair_translate.c