https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59708
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 33855 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33855&action=edit gcc5-pr59708-wip1.patch WIP untested patch, which implements so far the clang compatible builtins (with the exception of __builtin_umul*_overflow, that needs extra work) and has a start of implementation for the Joseph's idea of type-generic builtins (__builtin_{add,sub,mul}_overflow), which perform infinite precision signed +/-/*, store some low bits into the memory pointed by the third argument and return true iff the infinite precision signed result is equal to the stored value. Internally, where needed this is implemented as internal calls returning two values as a _Complex int, which turned out to be easiest and generates very good code during expansion. I'll work on BUILTIN_UMUL*_OVERFLOW next and when that is done, continue hacking on the type-generic stuff (so far it handles just the case where it is easy to prove the operation never overflows, or where it can be handled like the clang-compatible builtins (extended for other integral types like char/short/__int128).