From 71639eb837de8c71dbb8ee95496bbef5f9bc8c60 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 23 Jul 2024 15:34:06 -0500 Subject: [PATCH] nak: Use the RED path for atomics with unused destinations Part-of: --- src/nouveau/compiler/nak/from_nir.rs | 14 ++++++++++++-- src/nouveau/compiler/nak/ir.rs | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/nouveau/compiler/nak/from_nir.rs b/src/nouveau/compiler/nak/from_nir.rs index 411141aa0b6..911968a4a13 100644 --- a/src/nouveau/compiler/nak/from_nir.rs +++ b/src/nouveau/compiler/nak/from_nir.rs @@ -2160,8 +2160,15 @@ impl<'a> ShaderFromNir<'a> { self.get_src(&srcs[3]) }; + let is_reduction = + atom_op.is_reduction() && intrin.def.components_read() == 0; + b.push_op(OpSuAtom { - dst: dst.into(), + dst: if self.sm.sm() >= 70 && is_reduction { + Dst::None + } else { + dst.into() + }, fault: Dst::None, handle: handle, coord: coord, @@ -2329,8 +2336,11 @@ impl<'a> ShaderFromNir<'a> { assert!(intrin.def.num_components() == 1); let dst = b.alloc_ssa(RegFile::GPR, bit_size.div_ceil(32)); + let is_reduction = + atom_op.is_reduction() && intrin.def.components_read() == 0; + b.push_op(OpAtom { - dst: dst.into(), + dst: if is_reduction { Dst::None } else { dst.into() }, addr: addr, cmpr: 0.into(), data: data, diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 085b5a60ff4..b3209e63a7b 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -2410,6 +2410,22 @@ pub enum AtomOp { CmpExch(AtomCmpSrc), } +impl AtomOp { + pub fn is_reduction(&self) -> bool { + match self { + AtomOp::Add + | AtomOp::Min + | AtomOp::Max + | AtomOp::Inc + | AtomOp::Dec + | AtomOp::And + | AtomOp::Or + | AtomOp::Xor => true, + AtomOp::Exch | AtomOp::CmpExch(_) => false, + } + } +} + impl fmt::Display for AtomOp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self {