From 8170f18d9be6b4bc5e694f5c5568f5729bd3b7cd Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 13 Apr 2026 20:23:30 +0200 Subject: [PATCH] nak/copy_prop: allow modified F16v2 and F16 sources Seems to help a couple of shaders using MUFU.F16 Totals from 178 (0.01% of 1212873) affected shaders: CodeSize: 5929856 -> 5925088 (-0.08%); split: -0.08%, +0.00% Static cycle count: 8667151 -> 8665940 (-0.01%); split: -0.02%, +0.00% Reviewed-by: Mel Henning Part-of: --- src/nouveau/compiler/nak/ir.rs | 10 ++++++++++ src/nouveau/compiler/nak/opt_copy_prop.rs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 2f9feda1aad..6daf4a2b54a 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -1315,6 +1315,16 @@ pub enum SrcType { impl SrcType { const DEFAULT: SrcType = SrcType::GPR; + + pub fn is_fp16(&self) -> bool { + matches!(self, Self::F16 | Self::F16v2) + } + + /// Checks if consuming a value has the same semantics in regards to ftz + /// and modifiers. E.g. F16v2 and F16 would return true here. + pub fn eq_ftz_mod(&self, other: Self) -> bool { + *self == other || (self.is_fp16() && other.is_fp16()) + } } pub type SrcTypeList = AttrList; diff --git a/src/nouveau/compiler/nak/opt_copy_prop.rs b/src/nouveau/compiler/nak/opt_copy_prop.rs index ec3932baa0f..e1e2e3594bd 100644 --- a/src/nouveau/compiler/nak/opt_copy_prop.rs +++ b/src/nouveau/compiler/nak/opt_copy_prop.rs @@ -301,7 +301,8 @@ impl<'a> CopyPropPass<'a> { } // If there are modifiers, the source types have to match - if !entry.src.is_unmodified() && entry.src_type != src_type + if !entry.src.is_unmodified() + && !entry.src_type.eq_ftz_mod(src_type) { return; }