@shua asked a good question in GH https://github.com/roc-lang/roc/issues/3513#issuecomment-2508674491
I wanted to share here as it's easy to lose this kind of thing in the flood of GH messages.
question for add/sub/mul: should we be using x86/aarch64 carry flags when implementing these? It would mean we could implement the variants like
add
/addSaturated
/addChecked
/addWrap
all in asm for integers instead of calling out to bitcode. It also leads to a pretty conciseu128
/i128
impl foradd
andsub
.
that sounds like a great idea to me! :heart_eyes:
it looks like roc used the overflow flag in the x86 backend, but it got turned into a bitcode call while adding the aarch64 backend https://github.com/roc-lang/roc/pull/5824/files#diff-23699c56834955756a70ebbe1514d93b91f31073cbc15bc78a352ab70292b2c5L1376-R1385
was that intended to be temporary as aarch64 was added, or was there a reason to prefer calling the bitcode over the asm implementation? Maybe @Folkert de Vries remembers?
It was always just done for simplicity.
Better solutions are very welcome
For checked, it may have also been done to skip making a result (though that is pretty easy to do as well)
Last updated: Jul 06 2025 at 12:14 UTC