https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110304
--- Comment #11 from cqwrteur <unlvsur at live dot com> --- Actually mine template<::std::unsigned_integral T> inline constexpr T add_carry(T a,T b,T carryin,T& carryout) noexcept { [[assume(carryin==0||carryin==1)]]; a+=b; carryout=a<b; a+=carryin; carryout+=a<carryin; return a; } can be pattern-matching without builtins. This might be more universal and be optimized very early on.