nak: make is_fneg_zero detect -rZ
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33107>
This commit is contained in:
Thomas H.P. Andersen 2025-01-18 16:27:02 +01:00 committed by Marge Bot
parent 47fc468944
commit d55a69e769

View file

@ -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,