r300: optimize swizzle for inline constants

We can use any swizzle to access it, so if the inline constant is in
ADD,try to have the swizzle same as the second channel so that we can
potentially use presubtract later.

RV530:
total instructions in shared programs: 129366 -> 129306 (-0.05%)
instructions in affected programs: 10191 -> 10131 (-0.59%)
helped: 56
HURT: 12
total presub in shared programs: 8421 -> 8791 (4.39%)
presub in affected programs: 1523 -> 1893 (24.29%)
helped: 0
HURT: 102
total temps in shared programs: 17561 -> 17562 (<.01%)
temps in affected programs: 47 -> 48 (2.13%)
helped: 2
HURT: 4
total lits in shared programs: 3021 -> 3179 (5.23%)
lits in affected programs: 427 -> 585 (37.00%)
helped: 0
HURT: 37
total cycles in shared programs: 197845 -> 197512 (-0.17%)
cycles in affected programs: 18949 -> 18616 (-1.76%)
helped: 50
HURT: 19

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28428>
This commit is contained in:
Pavel Ondračka 2024-03-27 10:24:36 +01:00 committed by Marge Bot
parent e34bb4738a
commit 26836438cb
1 changed files with 12 additions and 3 deletions

View File

@ -122,9 +122,18 @@ void rc_inline_literals(struct radeon_compiler *c, void *user)
use_literal = 1;
}
/* Use RC_SWIZZLE_W for the inline constant, so
* it will become one of the alpha sources. */
SET_SWZ(src_reg.Swizzle, chan, RC_SWIZZLE_W);
/* We can use any swizzle, so if this is ADD it might
* be smart to us the same swizzle as the other src uses
* so that we potentially enable presubtract later.
* Use RC_SWIZZLE_W otherwise, so it will become one of
* the alpha sources.
*/
if (info->Opcode == RC_OPCODE_ADD &&
GET_SWZ(inst->U.I.SrcReg[1 - src_idx].Swizzle, chan) == chan) {
SET_SWZ(src_reg.Swizzle, chan, chan);
} else {
SET_SWZ(src_reg.Swizzle, chan, RC_SWIZZLE_W);
}
if (ret == -1) {
src_reg.Negate ^= (1 << chan);
}