pan/bi: Fix source swizzle in bi_repair_ssa

Repairing SSA was creating invalid PHI nodes with source swizzles !=
BI_SWIZZLE_H01. PHI sources can't have non-identity swizzles.

In most cases the repair logic only replaces sources, in which case the
swizzle is taken from the old source that is getting replaced. However,
in add_phi_operands there is no old source because the phi is new, and
so the result from resolve_read is assigned directly. This falsely
carries over the destination swizzle to the source.

Since it never makes sense for resolve_read to carry over the swizzle
from the instruction writing the value, we can make it so that
resolve_read always returns the identity swizzle on indices.
resolve_read returns one of:
- An index stored by record_write
- An index created by bi_temp_like
- The result of a recursive resolve_read call
bi_temp_like already correctly sets the swizzle to H01. Setting it in
record_write leads to both base cases returning the desired swizzle.

Fixes: dd94d183 ("pan/bi: Fixup bi_repair_ssa.c for bi")
Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40969>
This commit is contained in:
Christoph Pillmayer 2026-04-15 08:08:17 +02:00 committed by Marge Bot
parent 037873b8e1
commit fcfc580f67

View file

@ -50,6 +50,14 @@ record_write(struct repair_ctx *ctx, bi_block *block, unsigned node,
bi_index val)
{
assert(node < ctx->n);
/* The value always gets used as a source, where we don't want the
* destination "swizzle" and other modifiers that are applied on write.
*/
val.swizzle = BI_SWIZZLE_H01;
val.neg = false;
val.abs = false;
struct hash_table_u64 *defs = repair_block(ctx, block)->defs;
_mesa_hash_table_u64_insert(defs, node,
ralloc_memdup(defs, &val, sizeof(val)));
@ -106,6 +114,7 @@ resolve_read(struct repair_ctx *ctx, bi_block *block, bi_index node)
}
assert(!bi_is_null(val));
assert(val.swizzle == BI_SWIZZLE_H01);
record_write(ctx, block, node.value, val);
return val;
}