Suboptimal codegen using carrying_add for arbitrary precision

⚓ Rust    📅 2026-01-10    👤 surdeus    👁️ 1      

surdeus

I saw that u8::carrying_add has been stabilized, so I looked at the codegen when manually implementing a u128 add. It seems very bad. Am I using it wrong?

A godbolt link comparing some different attempts is here

None manage to replicate the assembly of u128::add, but the naive version is a lot closer than the u8::carrying_add version.

copy of code from godbolt link (click for more details) copy of asm (click for more details)

1 post - 1 participant

Read full topic

🏷️ Rust_feed