MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / scalar_add

Function scalar_add

app/src/ThirdParty/fast_float.h:3611–3628  ·  view source on GitHub ↗

add two small integers, checking for overflow. we want an efficient operation. for msvc, where we don't have built-in intrinsics, this is still pretty fast.

Source from the content-addressed store, hash-verified

3609// we don't have built-in intrinsics, this is still
3610// pretty fast.
3611fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb
3612scalar_add(limb x, limb y, bool &overflow) noexcept {
3613 limb z;
3614// gcc and clang
3615#if defined(__has_builtin)
3616#if __has_builtin(__builtin_add_overflow)
3617 if (!cpp20_and_in_constexpr()) {
3618 overflow = __builtin_add_overflow(x, y, &z);
3619 return z;
3620 }
3621#endif
3622#endif
3623
3624 // generic, this still optimizes correctly on MSVC.
3625 z = x + y;
3626 overflow = z < x;
3627 return z;
3628}
3629
3630// multiply two small integers, getting both the high and low bits.
3631fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb

Callers 3

scalar_mulFunction · 0.85
small_add_fromFunction · 0.85
large_add_fromFunction · 0.85

Calls 1

cpp20_and_in_constexprFunction · 0.85

Tested by

no test coverage detected