Changes in directory llvm-test/SingleSource/UnitTests:
2005-05-11-Popcount-ffs-fls.c updated: 1.4 -> 1.5 --- Log message: enhance this test to pass on non-gcc 4 host compilers --- Diffs of the changes: (+22 -1) 2005-05-11-Popcount-ffs-fls.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletion(-) Index: llvm-test/SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls.c diff -u llvm-test/SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls.c:1.4 llvm-test/SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls.c:1.5 --- llvm-test/SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls.c:1.4 Sun May 15 16:18:45 2005 +++ llvm-test/SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls.c Thu Jan 12 13:42:26 2006 @@ -24,6 +24,12 @@ return table[x >> 26]; } +int nlzll(unsigned long long x) { + if ((x >> 32) == 0) + return nlz10b(x)+32; + return nlz10b(x>>32); +} + int pop(unsigned x) { x = x - ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -33,6 +39,10 @@ return x >> 24; } +int popll(unsigned long long x) { + return pop(x) + pop(x >> 32); +} + int ntz8(unsigned x) { static char table[64] = @@ -45,6 +55,17 @@ return table[x >> 26]; } +/* Work with non-gcc compilers and GCC before 4.0 */ +#if !defined(__GNUC__) || __GNUC__ < 4 +#define __builtin_clz nlz10b +#define __builtin_popcount pop +#define __builtin_ctz ntz8 +#define __builtin_clzll nlzll +#define __builtin_popcountll popll +#define __builtin_ffsl __builtin_ffs +#define ffsl ffs +#endif + int i; int main(void) { long long l; @@ -66,7 +87,7 @@ printf("LLVM: n: %lld, clz(n): %d, popcount(n): %d, ctz(n): %d\n", l, __builtin_clzll(l), __builtin_popcountll(l), __builtin_ctz(l)); printf("REF LO BITS : n: %lld, clz(n): %d, popcount(n): %d, ctz(n): %d\n", - l, nlz10b(l), pop(l), ntz8(l)); + l, nlzll(l), popll(l), ntz8(l)); printf(" *** \n"); l++; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits