summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorMichal Terepeta <michal.terepeta@gmail.com>2019-03-24 13:58:53 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-04-01 20:07:49 -0400
commit7cf5ba3dba88356571197b470556e888581212d7 (patch)
tree6e89f905fe3f630ffa6684c661c374be2bfd5ff6 /includes
parent39282422afe58a0855c2fe5315163236c116c2f4 (diff)
downloadhaskell-7cf5ba3dba88356571197b470556e888581212d7.tar.gz
Improve performance of newSmallArray#
This: - Hoists part of the condition outside of the initialization loop in `stg_newSmallArrayzh`. - Annotates one of the unlikely branches as unlikely, also in `stg_newSmallArrayzh`. - Adds a couple of annotations to `allocateMightFail` indicating which branches are likely to be taken. Together this gives about 5% improvement. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Diffstat (limited to 'includes')
-rw-r--r--includes/Rts.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/includes/Rts.h b/includes/Rts.h
index a1a83397f3..f1f8351298 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -58,7 +58,13 @@ extern "C" {
#if __GNUC__ >= 4
#define RTS_UNLIKELY(p) __builtin_expect((p),0)
#else
-#define RTS_UNLIKELY(p) p
+#define RTS_UNLIKELY(p) (p)
+#endif
+
+#if __GNUC__ >= 4
+#define RTS_LIKELY(p) __builtin_expect(!!(p), 1)
+#else
+#define RTS_LIKELY(p) (p)
#endif
/* __builtin_unreachable is supported since GNU C 4.5 */