From ea41ecd1300ef1a600a5b2443b52783680f5e9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Wed, 15 Jan 2025 14:57:00 +0100 Subject: [PATCH] r300: fix presubtract assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only care that the negates of the relevant components are the same. Specifically the assert would incorectly trigger for code like this ADD temp[3].x, 1.250000 (0x3a).-x___, -const[0].x___; Signed-off-by: Pavel Ondračka Reviewed-by: Filip Gawin Part-of: --- src/gallium/drivers/r300/compiler/radeon_optimize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c index 7ed93f3aa78..46b1745b921 100644 --- a/src/gallium/drivers/r300/compiler/radeon_optimize.c +++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c @@ -374,7 +374,9 @@ presub_replace_add(struct rc_instruction *inst_add, struct rc_instruction *inst_ negates++; if (inst_add->U.I.SrcReg[1].Negate) negates++; - assert(negates != 2 || inst_add->U.I.SrcReg[1].Negate == inst_add->U.I.SrcReg[0].Negate); + assert(negates != 2 || + ((inst_add->U.I.SrcReg[1].Negate & inst_add->U.I.DstReg.WriteMask) == + (inst_add->U.I.SrcReg[0].Negate & inst_add->U.I.DstReg.WriteMask))); if (negates == 1) presub_opcode = RC_PRESUB_SUB;