commit f345412eb653cf7079996ad2c371def814f410b6
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Fri Apr 29 22:08:39 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Fri Apr 29 22:08:39 2016 +0200
Specify optimisation level on functions in zahl-inlines.h
Signed-off-by: Mattias Andrée <maandree_AT_kth.se>
diff --git a/src/internals.h b/src/internals.h
index a049e1a..04118e6 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -18,31 +18,13 @@
#define BITS_IN_LAST_CHAR(bits) ZAHL_BITS_IN_LAST_CHAR(bits)
#define TRUNCATE_TO_CHAR(bits) ZAHL_TRUNCATE_TO_CHAR(bits)
-#if defined(__GNUC__)
-# define O0 __attribute__((optimize("O0")))
-# define O1 __attribute__((optimize("O1")))
-# define O2 __attribute__((optimize("O2")))
-# define O3 __attribute__((optimize("O3")))
-# define Ofast __attribute__((optimize("Ofast")))
-# define Os __attribute__((optimize("Os")))
-# define Oz __attribute__((optimize("Os")))
-#elif defined(__clang__)
-# define O0 __attribute__((optnone))
-# define O1 /* Don't know how. */
-# define O2 /* Don't know how. */
-# define O3 /* Don't know how. */
-# define Ofast /* Don't know how. */
-# define Os /* Don't know how. */
-# define Oz /* Don't know how. */
-#else
-# define O0 /* Don't know how. */
-# define O1 /* Don't know how. */
-# define O2 /* Don't know how. */
-# define O3 /* Don't know how. */
-# define Ofast /* Don't know how. */
-# define Os /* Don't know how. */
-# define Oz /* Don't know how. */
-#endif
+#define O0 ZAHL_O0
+#define O1 ZAHL_O1
+#define O2 ZAHL_O2
+#define O3 ZAHL_O3
+#define Ofast ZAHL_Ofast
+#define Os ZAHL_Os
+#define Oz ZAHL_Oz
#define LIST_TEMPS\
X(libzahl_tmp_cmp, 1)\
diff --git a/zahl-inlines.h b/zahl-inlines.h
index abea865..1f04a05 100644
--- a/zahl-inlines.h
+++ b/zahl-inlines.h
_AT_@ -11,7 +11,7 @@ ZAHL_INLINE void zabs(z_t a, z_t b) { ZAHL_SET(a, b); a->sign = !!a->sign; }
ZAHL_INLINE void zneg(z_t a, z_t b) { ZAHL_SET(a, b); a->sign = -a->sign; }
-ZAHL_INLINE void
+ZAHL_INLINE ZAHL_O3 void
zswap(z_t a, z_t b)
{
/* Almost three times faster than the naïve method. */
_AT_@ -23,7 +23,7 @@ zswap(z_t a, z_t b)
}
-ZAHL_INLINE void
+ZAHL_INLINE ZAHL_O3 void
zseti(z_t a, int64_t b)
{
if (ZAHL_UNLIKELY(b >= 0)) {
_AT_@ -35,7 +35,7 @@ zseti(z_t a, int64_t b)
}
-ZAHL_INLINE void
+ZAHL_INLINE ZAHL_O3 void
zsetu(z_t a, uint64_t b)
{
if (!b) {
_AT_@ -49,7 +49,7 @@ zsetu(z_t a, uint64_t b)
}
-ZAHL_INLINE size_t
+ZAHL_INLINE ZAHL_O3 size_t
zlsb(z_t a)
{
size_t i = 0;
_AT_@ -62,7 +62,7 @@ zlsb(z_t a)
}
-ZAHL_INLINE size_t
+ZAHL_INLINE ZAHL_O3 size_t
zbits(z_t a)
{
size_t rc;
_AT_@ -75,7 +75,7 @@ zbits(z_t a)
}
-ZAHL_INLINE int
+ZAHL_INLINE ZAHL_O3 int
zcmpmag(z_t a, z_t b)
{
size_t i, j;
_AT_@ -103,7 +103,7 @@ zcmpmag(z_t a, z_t b)
}
-ZAHL_INLINE int
+ZAHL_INLINE ZAHL_O3 int
zcmp(z_t a, z_t b)
{
if (zsignum(a) != zsignum(b))
_AT_@ -112,7 +112,7 @@ zcmp(z_t a, z_t b)
}
-ZAHL_INLINE int
+ZAHL_INLINE ZAHL_O3 int
zcmpu(z_t a, uint64_t b)
{
extern z_t libzahl_tmp_cmp;
_AT_@ -125,7 +125,7 @@ zcmpu(z_t a, uint64_t b)
}
-ZAHL_INLINE int
+ZAHL_INLINE ZAHL_O3 int
zcmpi(z_t a, int64_t b)
{
extern z_t libzahl_tmp_cmp;
_AT_@ -147,7 +147,7 @@ zcmpi(z_t a, int64_t b)
}
-ZAHL_INLINE void
+ZAHL_INLINE ZAHL_O3 void
zbset(z_t a, z_t b, size_t bit, int action)
{
if (ZAHL_UNLIKELY(a != b))
_AT_@ -185,7 +185,7 @@ fallback:
}
-ZAHL_INLINE int
+ZAHL_INLINE ZAHL_O3 int
zbtest(z_t a, size_t bit)
{
size_t chars;
_AT_@ -201,7 +201,7 @@ zbtest(z_t a, size_t bit)
}
-ZAHL_INLINE void
+ZAHL_INLINE ZAHL_O3 void
zsplit(z_t high, z_t low, z_t a, size_t delim)
{
if (ZAHL_UNLIKELY(high == a)) {
_AT_@ -214,7 +214,7 @@ zsplit(z_t high, z_t low, z_t a, size_t delim)
}
-ZAHL_INLINE size_t
+ZAHL_INLINE ZAHL_O3 size_t
zsave(z_t a, void *buffer)
{
if (ZAHL_LIKELY(buffer)) {
diff --git a/zahl-internals.h b/zahl-internals.h
index 4adbdfe..83fd2e6 100644
--- a/zahl-internals.h
+++ b/zahl-internals.h
_AT_@ -19,6 +19,33 @@
#endif
+#if defined(__GNUC__) && !defined(__clang__)
+# define ZAHL_O0 __attribute__((optimize("O0")))
+# define ZAHL_O1 __attribute__((optimize("O1")))
+# define ZAHL_O2 __attribute__((optimize("O2")))
+# define ZAHL_O3 __attribute__((optimize("O3")))
+# define ZAHL_Ofast __attribute__((optimize("Ofast")))
+# define ZAHL_Os __attribute__((optimize("Os")))
+# define ZAHL_Oz __attribute__((optimize("Os")))
+#elif defined(__clang__)
+# define ZAHL_O0 __attribute__((optnone))
+# define ZAHL_O1 /* Don't know how. */
+# define ZAHL_O2 /* Don't know how. */
+# define ZAHL_O3 /* Don't know how. */
+# define ZAHL_Ofast /* Don't know how. */
+# define ZAHL_Os /* Don't know how. */
+# define ZAHL_Oz /* Don't know how. */
+#else
+# define ZAHL_O0 /* Don't know how. */
+# define ZAHL_O1 /* Don't know how. */
+# define ZAHL_O2 /* Don't know how. */
+# define ZAHL_O3 /* Don't know how. */
+# define ZAHL_Ofast /* Don't know how. */
+# define ZAHL_Os /* Don't know how. */
+# define ZAHL_Oz /* Don't know how. */
+#endif
+
+
#define ZAHL_BITS_PER_CHAR 64
#define ZAHL_LB_BITS_PER_CHAR 6
#define ZAHL_CHAR_MAX UINT64_MAX
_AT_@ -78,14 +105,14 @@ struct zahl {
void libzahl_realloc(struct zahl *, size_t);
-static inline void
+ZAHL_O3 static inline void
libzahl_memcpy(zahl_char_t *restrict d, const zahl_char_t *restrict s, register size_t n)
{
while (n--)
d[n] = s[n];
}
-static inline void
+ZAHL_O3 static inline void
libzahl_memset(zahl_char_t *a, register zahl_char_t v, register size_t n)
{
while (n--)
Received on Fri Apr 29 2016 - 22:09:51 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 29 2016 - 22:12:16 CEST