diff options
author | Chris Robinson <[email protected]> | 2018-04-21 01:54:43 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-04-21 01:54:43 -0700 |
commit | a55c93e1f59dfadda64a63e4c1b0881ca34dbad8 (patch) | |
tree | bd1f5ea97b5e7f04f965f0b8cc0185935eeea70a /OpenAL32 | |
parent | 400ab8766c02e76bce4c989768a9cd2f6e330f49 (diff) |
Improve ASSUME for Clang
For some reason, the { if(!x)__builtin_unreachable(); } construct does not
provide the same optimization opportunity for Clang (even though the condition
being false would trigger undefined behavior by reaching unreachable code, it
still performs checks and such for the condition potentially being false).
Using __builtin_assume seems to work better.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 77144a29..48d8fb4a 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -40,6 +40,11 @@ #define SZFMT "%zu" #endif +#ifdef __has_builtin +#define HAS_BUILTIN __has_builtin +#else +#define HAS_BUILTIN(x) (0) +#endif #ifdef __GNUC__ /* LIKELY optimizes the case where the condition is true. The condition is not @@ -53,7 +58,11 @@ * undefined behavior. It's essentially an assert without actually checking the * condition at run-time, allowing for stronger optimizations than LIKELY. */ +#if HAS_BUILTIN(__builtin_assume) +#define ASSUME __builtin_assume +#else #define ASSUME(x) do { if(!(x)) __builtin_unreachable(); } while(0) +#endif #else |