From 26272f67557fa7940d614952d649ba419f617573 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 1 Aug 2019 06:50:13 +0000 Subject: [PATCH] if 0 out our klabs() function and just define it as abs() The compiler generates much better code for this now. git-svn-id: https://svn.eduke32.com/eduke32@7863 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/pragmas.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 18e4770d4..9d0f33570 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -241,11 +241,15 @@ static FORCE_INLINE CONSTEXPR char readpixel(void *s) { return *(char *)s; } static FORCE_INLINE void drawpixel(void *s, char a) { *(char *)s = a; } #ifndef pragmas_have_klabs -static FORCE_INLINE int32_t klabs(int32_t a) +#if 0 +static FORCE_INLINE int32_t klabs(int32_t const a) { - const uint32_t m = a >> (sizeof(uint32_t) * CHAR_BIT - 1); + uint32_t const m = a >> (sizeof(uint32_t) * CHAR_BIT - 1); return (a ^ m) - m; } +#else +#define klabs(x) abs(x) +#endif #endif #ifndef pragmas_have_ksgn static FORCE_INLINE CONSTEXPR int32_t ksgn(int32_t a) { return (a > 0) - (a < 0); }