3 ms·
This seems to work. The compiler has to see the previous add to know what is in the carry flag. #include <stdint.h> uint64_t addWithCarry(uint64_t x,
by haberman 6y ago
This seems to work. The compiler has to see the previous add to know what is in the carry flag.
#include <stdint.h>
uint64_t addWithCarry(uint64_t x, uint64_t y, uint64_t z) {
return x + y + (y + z < y);
}
Output here: https://godbolt.org/z/zfP7PnGcs https://godbolt.org/z/zfP7PnGcs