search for: saddo_portable

Displaying 1 result from an estimated 1 matches for "saddo_portable".

Did you mean: uaddo_portable
2018 Nov 20
2
A pattern for portable __builtin_add_overflow()
...table: # @uaddo_portable xor eax, eax add edi, esi setb al mov dword ptr [rdx], edi ret But with signed types it is not so easy. I tried 2 versions, but the result is quite far away from the optimal assembly. int saddo_native(int a, int b, int* s) { return __builtin_add_overflow(a, b, s); } int saddo_portable(int a, int b, int* s) { *s = (unsigned)a + (unsigned)b; return (a > 0) ? *s <= b : *s > b; } int saddo_portable2(int a, int b, int* s) { *s = (unsigned)a + (unsigned)b; int cond = a > 0; int check = *s > b; return (cond & !check) | (!cond & check); } Assembly: saddo_native...