aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-04-21 01:54:43 -0700
committerChris Robinson <[email protected]>2018-04-21 01:54:43 -0700
commita55c93e1f59dfadda64a63e4c1b0881ca34dbad8 (patch)
treebd1f5ea97b5e7f04f965f0b8cc0185935eeea70a /OpenAL32/Include
parent400ab8766c02e76bce4c989768a9cd2f6e330f49 (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/Include')
-rw-r--r--OpenAL32/Include/alMain.h9
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