diff --git a/src/internal/libm.h b/src/internal/libm.h index 62da4bdb29f1ae0ed88303f058c2b65c1164deb7..28537603a78408e64e0bfca4b812411888f0e716 100644 --- a/src/internal/libm.h +++ b/src/internal/libm.h @@ -59,6 +59,15 @@ union ldshape { #error Unsupported long double representation #endif +/* Helps static branch prediction so hot path can be better optimized. */ +#ifdef __GNUC__ +#define predict_true(x) __builtin_expect(!!(x), 1) +#define predict_false(x) __builtin_expect(x, 0) +#else +#define predict_true(x) (x) +#define predict_false(x) (x) +#endif + /* Evaluate an expression as the specified type. With standard excess precision handling a type cast or assignment is enough (with -ffloat-store an assignment is required, in old compilers argument