pan/valhall: fuse_cmp skip when fusing the same instruction

CSE can cause some cases where we had

%3 = ICMP_OR %1, %2, 0
%4 = ICMP_OR %1, %2, 0
%5 = LSHIFT_AND %3, %4

To become

%3 = ICMP_OR %1, %2, 0
%5 = LSHIFT_AND %3, %3

The va_fuse_cmp pass would try to rewrite this as
%3 = ICMP_AND %1, %2, %3

But this is obviously wrong, we should not fuse the same instruction
together.

Fixes: 800a861431 ("pan/bi: Fuse FCMP/ICMP on Valhall")
Signed-off-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Found-by: Ryan Zhang <ryan.zhang@nxp.com>
Reviewed-by: Ryan Zhang <ryan.zhang@nxp.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41504>
This commit is contained in:
Lorenzo Rossi 2026-05-12 12:17:48 +02:00 committed by Marge Bot
parent d445a950fd
commit 0a4b7f69c1

View file

@ -227,6 +227,13 @@ va_fuse_cmp(bi_context *ctx, bi_instr **lut, const BITSET_WORD *multiple,
bi_instr *src0_ins = lut[I->src[0].value];
bi_instr *src1_ins = lut[I->src[1].value];
/* %1 = FCMP(a, b)
* %2 = LSHIFT_X(%1, %1, 0)
* We cannot fold that.
*/
if (src0_ins == src1_ins)
return false;
enum va_cmp_type cmp_type = va_cmp_opcode_to_cmp_type(src0_ins->op);
/* Expect both side to use the same form type */