diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index c15e52ad733..0dd22c42852 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -505,6 +505,14 @@ impl Dst { Dst::Reg(reg) => reg.comps(), } } + + pub fn file(&self) -> Option { + match self { + Dst::None => None, + Dst::SSA(ssa) => Some(ssa.file()), + Dst::Reg(reg) => Some(reg.file()), + } + } } impl From for Dst { diff --git a/src/nouveau/compiler/nak/sm75_instr_latencies.rs b/src/nouveau/compiler/nak/sm75_instr_latencies.rs index fd820dcf511..0b20e8d9bd7 100644 --- a/src/nouveau/compiler/nak/sm75_instr_latencies.rs +++ b/src/nouveau/compiler/nak/sm75_instr_latencies.rs @@ -1215,10 +1215,8 @@ impl SM75Latency { read: Option<&Op>, src_idx: usize, ) -> u32 { - let dst_file = match &write.dsts_as_slice()[dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else { + return 0; }; match dst_file { @@ -1274,10 +1272,8 @@ impl SM75Latency { } pub fn war(read: &Op, src_idx: usize, write: &Op, dst_idx: usize) -> u32 { - let dst_file = match &write.dsts_as_slice()[dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else { + return 0; }; match dst_file { @@ -1330,10 +1326,8 @@ impl SM75Latency { b_dst_idx: usize, a_op_pred: bool, ) -> u32 { - let dst_file = match &a.dsts_as_slice()[a_dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = a.dsts_as_slice()[a_dst_idx].file() else { + return 0; }; match dst_file { diff --git a/src/nouveau/compiler/nak/sm80_instr_latencies.rs b/src/nouveau/compiler/nak/sm80_instr_latencies.rs index 1cb8de4c08d..bdbd278c65a 100644 --- a/src/nouveau/compiler/nak/sm80_instr_latencies.rs +++ b/src/nouveau/compiler/nak/sm80_instr_latencies.rs @@ -1473,10 +1473,8 @@ impl SM80Latency { read: Option<&Op>, src_idx: usize, ) -> u32 { - let dst_file = match &write.dsts_as_slice()[dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else { + return 0; }; match dst_file { @@ -1530,10 +1528,8 @@ impl SM80Latency { } pub fn war(read: &Op, src_idx: usize, write: &Op, dst_idx: usize) -> u32 { - let dst_file = match &write.dsts_as_slice()[dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = write.dsts_as_slice()[dst_idx].file() else { + return 0; }; match dst_file { @@ -1582,10 +1578,8 @@ impl SM80Latency { b_dst_idx: usize, a_op_pred: bool, ) -> u32 { - let dst_file = match &a.dsts_as_slice()[a_dst_idx] { - Dst::None => return 0, - Dst::SSA(vec) => vec.file(), - Dst::Reg(reg) => reg.file(), + let Some(dst_file) = a.dsts_as_slice()[a_dst_idx].file() else { + return 0; }; match dst_file {