From 10396d8db6e3d7341d8f93083f9186503defdfe9 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sat, 4 Oct 2025 16:16:36 +0200 Subject: [PATCH] nak: remove conversion into the same type Part-of: --- src/nouveau/compiler/nak/assign_regs.rs | 9 +++------ src/nouveau/compiler/nak/builder.rs | 6 +++--- src/nouveau/compiler/nak/from_nir.rs | 8 ++++---- src/nouveau/compiler/nak/hw_tests.rs | 10 +++++----- src/nouveau/compiler/nak/qmd.rs | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/nouveau/compiler/nak/assign_regs.rs b/src/nouveau/compiler/nak/assign_regs.rs index 42d5c99ebbc..4142038dc28 100644 --- a/src/nouveau/compiler/nak/assign_regs.rs +++ b/src/nouveau/compiler/nak/assign_regs.rs @@ -846,12 +846,9 @@ fn instr_assign_regs_file( } let align = vec_dst.comps.next_power_of_two(); - if let Some(reg) = ra.try_find_unused_reg_range( - next_dst_reg, - vec_dst.comps.try_into().unwrap(), - align, - 0, - ) { + if let Some(reg) = + ra.try_find_unused_reg_range(next_dst_reg, vec_dst.comps, align, 0) + { vec_dst.reg = reg; next_dst_reg = reg + u32::from(vec_dst.comps); } else { diff --git a/src/nouveau/compiler/nak/builder.rs b/src/nouveau/compiler/nak/builder.rs index b01c87a9d84..f5e51df764f 100644 --- a/src/nouveau/compiler/nak/builder.rs +++ b/src/nouveau/compiler/nak/builder.rs @@ -728,7 +728,7 @@ pub trait SSABuilder: Builder { op: RroOp::SinCos, src, }); - tmp.into() + tmp }; self.mufu(MuFuOp::Sin, tmp.into()) } @@ -744,7 +744,7 @@ pub trait SSABuilder: Builder { op: RroOp::SinCos, src, }); - tmp.into() + tmp }; self.mufu(MuFuOp::Cos, tmp.into()) } @@ -861,7 +861,7 @@ pub trait SSABuilder: Builder { self.alloc_ssa(RegFile::GPR) }; self.copy_to(dst.into(), src); - dst.into() + dst } fn bmov_to_bar(&mut self, src: Src) -> SSAValue { diff --git a/src/nouveau/compiler/nak/from_nir.rs b/src/nouveau/compiler/nak/from_nir.rs index 6ce15dca840..76edf70ea3d 100644 --- a/src/nouveau/compiler/nak/from_nir.rs +++ b/src/nouveau/compiler/nak/from_nir.rs @@ -1368,7 +1368,7 @@ impl<'a> ShaderFromNir<'a> { let src = srcs(0).to_ssa(); if src_bits == 64 { if dst_bits == 64 { - src.into() + src } else { b.prmt(src[0].into(), src[1].into(), prmt_lo).into() } @@ -3822,7 +3822,7 @@ impl<'a> ShaderFromNir<'a> { dst_type: dst_type, src_type: FloatType::F16, mat_size: mat_size, - srcs: [cmat_a.into(), cmat_b.into(), cmat_c.into()], + srcs: [cmat_a, cmat_b, cmat_c], }); } NAK_CMAT_TYPE_M8N8K16_INT @@ -3849,7 +3849,7 @@ impl<'a> ShaderFromNir<'a> { b.push_op(OpImma { dst: dst.clone().into(), mat_size, - srcs: [cmat_a.into(), cmat_b.into(), cmat_c.into()], + srcs: [cmat_a, cmat_b, cmat_c], src_types: [a_type, b_type], saturate: flags.sat(), }); @@ -3857,7 +3857,7 @@ impl<'a> ShaderFromNir<'a> { val => unreachable!("Unknown cmat_type {val}"), } - self.set_dst(&intrin.def, dst.into()); + self.set_dst(&intrin.def, dst); } _ => panic!( "Unsupported intrinsic instruction: {}", diff --git a/src/nouveau/compiler/nak/hw_tests.rs b/src/nouveau/compiler/nak/hw_tests.rs index b36683521e9..3204efa8382 100644 --- a/src/nouveau/compiler/nak/hw_tests.rs +++ b/src/nouveau/compiler/nak/hw_tests.rs @@ -404,7 +404,7 @@ pub fn test_foldable_op_with( for ssa in &vec[..] { let u = match ssa.file() { RegFile::Pred => b.sel((*ssa).into(), 1.into(), 0.into()), - RegFile::GPR => (*ssa).into(), + RegFile::GPR => *ssa, RegFile::Carry => { let gpr = b.alloc_ssa(RegFile::GPR); b.push_op(OpIAdd2X { @@ -413,7 +413,7 @@ pub fn test_foldable_op_with( srcs: [0.into(), 0.into()], carry_in: (*ssa).into(), }); - gpr.into() + gpr } file => panic!("Can't auto-test {file:?} data"), }; @@ -1666,7 +1666,7 @@ fn test_op_ldsm() { b.push_op(OpSt { addr: offset.into(), data: input.into(), - offset: 0.into(), + offset: 0, access: MemAccess { mem_type: MemType::B128, space: MemSpace::Shared, @@ -1685,9 +1685,9 @@ fn test_op_ldsm() { mat_size: LdsmSize::M8N8, mat_count: 4, addr: addr.into(), - offset: 0.into(), + offset: 0, }); - b.st_test_data(16, MemType::B128, res.into()); + b.st_test_data(16, MemType::B128, res); type Data = [u16; 4 * 2 * 2]; b.set_shared_size((size_of::() * 32 / 2) as u16); diff --git a/src/nouveau/compiler/nak/qmd.rs b/src/nouveau/compiler/nak/qmd.rs index 6352ef4dbac..281937afc28 100644 --- a/src/nouveau/compiler/nak/qmd.rs +++ b/src/nouveau/compiler/nak/qmd.rs @@ -642,7 +642,7 @@ fn fill_qmd( qmd.set_slm_size(info.slm_size); assert!(qmd_info.smem_size <= u32::from(dev.max_smem_per_wg_kB) * 1024); - qmd.set_smem_size(qmd_info.smem_size.into(), dev, info); + qmd.set_smem_size(qmd_info.smem_size, dev, info); for i in 0..qmd_info.num_cbufs { let cb = &qmd_info.cbufs[usize::try_from(i).unwrap()];