pan/bi: Constant fold swizzles on constants

This lets us avoid generating SWZ instructions. Those instructions could
be constant folded but that complicates the replication analysis
introduced in the next commit.

Almost no shader-db changes.

quadwords HURT:   shaders/glmark/1-22.shader_test MESA_SHADER_FRAGMENT: 718 -> 722 (0.56%)

total quadwords in shared programs: 68169 -> 68173 (<.01%)
quadwords in affected programs: 718 -> 722 (0.56%)
helped: 0
HURT: 1

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14576>
This commit is contained in:
Alyssa Rosenzweig 2022-01-15 12:25:45 -05:00 committed by Marge Bot
parent 62533a6e64
commit 35ff537814

View file

@ -108,7 +108,21 @@ bi_lower_swizzle_16(bi_context *ctx, bi_instr *ins, unsigned src)
return;
}
/* If the instruction is scalar we can ignore the other component */
/* First, try to apply a given swizzle to a constant to clear the
* runtime swizzle. This is less heavy-handed than ignoring the
* swizzle for scalar destinations, since it maintains
* replication of the destination.
*/
if (ins->src[src].type == BI_INDEX_CONSTANT) {
ins->src[src].value = bi_apply_swizzle(ins->src[src].value,
ins->src[src].swizzle);
ins->src[src].swizzle = BI_SWIZZLE_H01;
return;
}
/* Even if the source does not replicate, if the consuming instruction
* produces a 16-bit scalar, we can ignore the other component.
*/
if (ins->dest[0].swizzle == BI_SWIZZLE_H00 &&
ins->src[src].swizzle == BI_SWIZZLE_H00)
{