by adwn · 5y ago · 0 comments
pub fn divmod10(x: u32) -> (u32, u32) {
(x / 10, x % 10)
}
generates mov ecx, edi
mov eax, 3435973837
imul rax, rcx
shr rax, 35
lea ecx, [rax + rax]
lea ecx, [rcx + 4\*rcx]
sub edi, ecx
mov edx, edi
retUsing a decimal expansion adds 25% overhead from pure maths. Your cache will be larger if you're working in base ten regardless of what optimizations your compiler does.