Commit 1efd0b97 by Richard Henderson Committed by Richard Henderson

longlong.h [alpha] (count_leading_zeros, [...]): Use builtins instead of inline assembly.

        * longlong.h [alpha] (count_leading_zeros, count_trailing_zeros): Use
        builtins instead of inline assembly.

From-SVN: r62407
parent 087fc75a
2003-02-04 Richard Henderson <rth@redhat.com>
* longlong.h [alpha] (count_leading_zeros, count_trailing_zeros): Use
builtins instead of inline assembly.
2003-02-04 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> 2003-02-04 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
PR c/9376 PR c/9376
......
...@@ -128,30 +128,28 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); ...@@ -128,30 +128,28 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
#define UDIV_TIME 220 #define UDIV_TIME 220
#endif /* LONGLONG_STANDALONE */ #endif /* LONGLONG_STANDALONE */
#ifdef __alpha_cix__ #ifdef __alpha_cix__
#define count_leading_zeros(COUNT,X) \ #define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X))
__asm__("ctlz %1,%0" : "=r"(COUNT) : "r"(X)) #define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
#define count_trailing_zeros(COUNT,X) \
__asm__("cttz %1,%0" : "=r"(COUNT) : "r"(X))
#define COUNT_LEADING_ZEROS_0 64 #define COUNT_LEADING_ZEROS_0 64
#else #else
extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN; extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
#define count_leading_zeros(COUNT,X) \ #define count_leading_zeros(COUNT,X) \
do { \ do { \
UDItype __xr = (X), __t, __a; \ UDItype __xr = (X), __t, __a; \
__asm__("cmpbge $31,%1,%0" : "=r"(__t) : "r"(__xr)); \ __t = __builtin_alpha_cmpbge (0, __xr); \
__a = __clz_tab[__t ^ 0xff] - 1; \ __a = __clz_tab[__t ^ 0xff] - 1; \
__asm__("extbl %1,%2,%0" : "=r"(__t) : "r"(__xr), "r"(__a)); \ __t = __builtin_alpha_extbl (__xr, __a); \
(COUNT) = 64 - (__clz_tab[__t] + __a*8); \ (COUNT) = 64 - (__clz_tab[__t] + __a*8); \
} while (0) } while (0)
#define count_trailing_zeros(COUNT,X) \ #define count_trailing_zeros(COUNT,X) \
do { \ do { \
UDItype __xr = (X), __t, __a; \ UDItype __xr = (X), __t, __a; \
__asm__("cmpbge $31,%1,%0" : "=r"(__t) : "r"(__xr)); \ __t = __builtin_alpha_cmpbge (0, __xr); \
__t = ~__t & -~__t; \ __t = ~__t & -~__t; \
__a = ((__t & 0xCC) != 0) * 2; \ __a = ((__t & 0xCC) != 0) * 2; \
__a += ((__t & 0xF0) != 0) * 4; \ __a += ((__t & 0xF0) != 0) * 4; \
__a += ((__t & 0xAA) != 0); \ __a += ((__t & 0xAA) != 0); \
__asm__("extbl %1,%2,%0" : "=r"(__t) : "r"(__xr), "r"(__a)); \ __t = __builtin_alpha_extbl (__xr, __a); \
__a <<= 3; \ __a <<= 3; \
__t &= -__t; \ __t &= -__t; \
__a += ((__t & 0xCC) != 0) * 2; \ __a += ((__t & 0xCC) != 0) * 2; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment