From d55a69e76939b312fd56d15cbe706cda3e1ad6b4 Mon Sep 17 00:00:00 2001 From: "Thomas H.P. Andersen" Date: Sat, 18 Jan 2025 16:27:02 +0100 Subject: [PATCH] nak: make is_fneg_zero detect -rZ fold_imm starts with this check: let SrcRef::Imm32(mut u) = self.src_ref else { return *self; }; For -rZ we thus return early and the matching in is_fneg_zero does not find it. This MR adds a match for SrcRef::Zero + SrcMod::FNeg. This lets copy propagation fold this: r3 = shfl.bfly r2 0x2 0x1c03 r3 = fswzadd.ftz r3 r2 [sub, sub, subr, subr] r3 = fadd.ftz -rZ |r3| r16 = shfl.bfly r2 0x1 0x1c03 r16 = fswzadd.ftz r16 r2 [sub, subr, sub, subr] r16 = fadd.ftz -rZ |r16| r3 = fadd.ftz r16 r3 into: r3 = shfl.bfly r2 0x2 0x1c03 r3 = fswzadd.ftz r3 r2 [sub, sub, subr, subr] r16 = shfl.bfly r2 0x1 0x1c03 r16 = fswzadd.ftz r16 r2 [sub, subr, sub, subr] r3 = fadd.ftz |r16| |r3| Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12480 Part-of: --- src/nouveau/compiler/nak/ir.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 2ad1ecb7d1d..7895eb8e8d2 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -1309,6 +1309,7 @@ impl Src { pub fn is_fneg_zero(&self, src_type: SrcType) -> bool { match self.fold_imm(src_type).src_ref { + SrcRef::Zero => self.src_mod == SrcMod::FNeg, SrcRef::Imm32(0x00008000) => src_type == SrcType::F16, SrcRef::Imm32(0x80000000) => src_type == SrcType::F32, SrcRef::Imm32(0x80008000) => src_type == SrcType::F16v2,