From f4be78358cda64fdcfb466660598dbeb7218d9e4 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 16 Jun 2026 14:39:31 -0400 Subject: [PATCH] kraid: Add an SSAValue::bytes() helper This is just bits() divided by 8 but it's a bit more efficient and we want bytes often enough that we might as well have the helper. Part-of: --- src/panfrost/compiler/kraid/ssa_value.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panfrost/compiler/kraid/ssa_value.rs b/src/panfrost/compiler/kraid/ssa_value.rs index 25f2fa2fa7d..00dd218878a 100644 --- a/src/panfrost/compiler/kraid/ssa_value.rs +++ b/src/panfrost/compiler/kraid/ssa_value.rs @@ -37,6 +37,11 @@ impl SSAValue { pub fn bits(&self) -> u8 { 8 << (self.packed.get() >> 30) } + + /// Returns the number of bytes in this SSA value + pub fn bytes(&self) -> u8 { + 1 << (self.packed.get() >> 30) + } } impl IntoBitIndex for SSAValue { @@ -109,7 +114,7 @@ impl SSARef { pub fn bytes(&self) -> u8 { if self.comps() == 1 { - self[0].bits() / 8 + self[0].bytes() } else { for ssa in self { debug_assert_eq!(ssa.bits(), 32); @@ -300,6 +305,7 @@ mod tests { let ssa = SSAValue::new(42, bits); assert_eq!(ssa.idx(), 42); assert_eq!(ssa.bits(), bits); + assert_eq!(ssa.bytes(), bits / 8); } }