search for: __builtin_clz

Displaying 20 results from an estimated 27 matches for "__builtin_clz".

2006 Jun 26
5
__builtin_clz in klibc
Hi, I just got a bug report that klibc doesn't compile on s390: KLIBCCC usr/klibc/libgcc/__clzsi2.o KLIBCCC usr/klibc/libgcc/__clzdi2.o usr/klibc/libgcc/__clzdi2.c: In function `__clzdi2': usr/klibc/libgcc/__clzdi2.c:24: warning: implicit declaration of function `__builtin_clz' This looks like a common problem, because __builtin_clz is available since gcc 3.4, while the kernel should compile even with gcc 3.2. Looks like counting the zero bits should be done differently...
2017 Jun 02
3
Dovecot 2.2.30* compiling error
...--without-mysql \ --without-sqlite \ --with-rundir=/var/run/dovecot\ --without-deliver \ --without-gssapi Build error: ltest_lib-test-bits.o: In function `bits_required64': /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined reference to `__builtin_clzll' /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined reference to `__builtin_clzll' test_lib-test-bits.o: In function `test_bits_requiredXX': /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/test-bits.c:74: undefined reference to `__builtin_clzll' /usr/src/redhat/BUILD/d...
2012 May 09
1
[PATCH 2/2] bitmath: Finish up optimizations
...uint32_t is >= 32 bits wide */ /* also, some sections currently only have fast versions for 4 or 8 bytes per word */ #define FLAC__BYTES_PER_WORD 4 /* sizeof uint32_t */ @@ -56,27 +56,6 @@ #define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x) #endif -#if defined(__GNUC__) -/* "int __builtin_clz (unsigned int x) If x is 0, the result is undefined" */ -static inline uint32_t -COUNT_ZERO_MSBS (uint32_t word) -{ - if (word == 0) - return 32; - return __builtin_clz (word); -} -#else -/* counts the # of zero MSBs in a word */ -#define COUNT_ZERO_MSBS(word) ( \ - (word) > 0xffffff ? byt...
2013 Aug 16
2
[LLVMdev] ctlz pattern
Does anyone know some simple c/c++ code or .ll code which will cause this ctlz pattern to be emitted? Tia. Reed
2013 Aug 16
0
[LLVMdev] ctlz pattern
Are you looking for something other than calling __builtin_clz from c++ or calling @llvm.ctlz.* instrinsic from IR? I don't think we have anything that will auto converting a loop to ctlz or anything like that. We only seem to have a detection for popcount loops. On Thu, Aug 15, 2013 at 9:01 PM, reed kotler <rkotler at mips.com> wrote: > Does...
2015 Dec 28
1
[PATCH 2] more changes in bitmath.h
...z_uint32(v) ^ 31U" (and the same for 64-bit version). "sizeof(FLAC__uint32) * CHAR_BIT" must be 32, or the code won't work. So it's simpler to use "31 - FLAC__clz_uint32(v)" or even better, "FLAC__clz_uint32(v) ^ 31". Why XORing is better: gcc implements __builtin_clz as bsr^31, so FLAC__bitmath_ilog2() now calculates 31 - (bsr^31). GCC is unable to simplify it to just bsr. But it can do it for (bsr^31)^31. 5) The patch adds FLAC__U64L() for a big constant. -------------- next part -------------- A non-text attachment was scrubbed... Name: 2_bitmath_h.patch Ty...
2007 Nov 05
1
klibc sparc trouble with gcc > 4.0
...er of 0 bits in the argument + */ + +#include <stdint.h> +#include <stddef.h> + +uint64_t __clzdi2(uint64_t v) +{ + uint32_t vhi = (uint32_t) (v >> 32); + uint32_t vx; + int dp; + + if (vhi) { + vx = vhi; + dp = 0; + } else { + vx = (uint32_t) v; + dp = 32; + } + + return dp + __builtin_clz(vx); +}
2012 Jul 29
3
[LLVMdev] rotate
...shifts and on intel shifts are mod the register > size [...snip...] I remember finding the same thing (although I haven't tried it on a recent clang version) and what I wondered was whether there was mileage in having an explicit intrinsic for rotation (like there is for bit counting, as in __builtin_clz and __builtin_ctz and so on). Microsoft's compiler has an explicit intrinsic in the form of _rotl8 and _rotl16 (IIRC -- this is from memory!). It would be nice to have a __builtin_rotl family in clang, in my opinion, but it would need back-end support from llvm. I would expect it to find use...
2009 Feb 26
1
[LLVMdev] A simple question regarding LLVM intrinsics.
Hi. My name is Gil Dogon and I am working in MobileEye using LLVM in order to generate code for a proprietary processor. Our processor architecture is very similar to MIPS, so I started to work using the "experimental" MIPS back end. Anyway, my question is rather simple but somehow I did not find a quick answer to it in the documentation. What I want to know, is how can the
2009 Feb 26
1
[LLVMdev] A partial reply to the previous question and another one
OK , grepping the whole source tree for 'ctlz' I found the answer to my question in: test/FrontendC/2006-01-16-BitCountIntrinsicsUnsigned.c and that is to use gnu frontend style __builtin_clz() for this one. This test/FrontendC directory has a plethora of other usefull examples so I guess It will be sufficient for me. However I still think that some documentation of the frontend interface for the intrinsics is sorely missing. Or is it that LLVM is supposed to support ALL of gnu'...
2017 Jun 02
0
Dovecot 2.2.30* compiling error
...0*, but I can build fine version 2.2.29* with same > options: > RedHat based customized distro, 2.6.28.10 kernel [...] > Build error: > ltest_lib-test-bits.o: In function `bits_required64': > /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined > reference to `__builtin_clzll' > /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined > reference to `__builtin_clzll' > test_lib-test-bits.o: In function `test_bits_requiredXX': > /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/test-bits.c:74: undefined > reference to `__builtin_clzll'...
2013 Aug 16
1
PATCH for bitmath.h: 1 typo, 1 warning
...C__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) /* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on - * -march= setting or to a software rutine in exotic machines. */ + * -march= setting or to a software routine in exotic machines. */ return __builtin_clz(v); #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - FLAC__uint32 idx; + unsigned long idx; _BitScanReverse(&idx, v); - return idx ^ 31U; + return (unsigned)idx ^ 31U; #else return FLAC__clz_soft_uint32(v); #endif
2013 Sep 06
4
About de Bruijn sequences in bitmath.h
Found this code: ftp://ftp.samba.org/pub/unpacked/ntdb/lib/ccan/ilog/ilog.c Tests show that it's faster to use the following code in FLAC__bitmath_ilog2_wide(): static const unsigned char DEBRUIJN_IDX32[32]={ 0, 1,28, 2,29,14,24, 3,30,22,20,15,25,17, 4, 8, 31,27,13,23,21,19,16, 7,26,12,18, 6,11, 5,10, 9 }; FLAC__uint32 v; int m;
2014 Jan 25
0
[klibc:master] i386: use the vdso for system calls on i386
...e = __auxval[AT_PAGESZ]; +#ifdef __i386__ + { + extern void (*__syscall_entry)(int, ...); + if (__auxval[AT_SYSINFO]) + __syscall_entry = (void (*)(int, ...)) + __auxval[AT_SYSINFO]; + } +#endif + #if __GNUC__ >= 4 /* unsigned int is 32 bits on all our architectures */ page_shift = __builtin_clz(page_size) ^ 31;
2012 Jul 29
0
[LLVMdev] rotate
*NOTE* IIRC compiling this with -O0 on x86-64 can yield the wrong result since clang will emit shifts and on intel shifts are mod the register size: ===== .section __TEXT,__text,regular,pure_instructions .globl _ror .align 4, 0x90 _ror: ## @ror .cfi_startproc ## BB#0: pushq %rbp Ltmp2: .cfi_def_cfa_offset 16 Ltmp3: .cfi_offset %rbp, -16 movq %rsp, %rbp
2014 Apr 09
0
[klibc:master] Move architecture-specific initialization to arch/
...e = __auxval[AT_PAGESZ]; -#ifdef __i386__ - { - extern void (*__syscall_entry)(int, ...); - if (__auxval[AT_SYSINFO]) - __syscall_entry = (void (*)(int, ...)) - __auxval[AT_SYSINFO]; - } -#endif - #if __GNUC__ >= 4 /* unsigned int is 32 bits on all our architectures */ page_shift = __builtin_clz(page_size) ^ 31; #elif defined(__i386__) || defined(__x86_64__) - asm("bsrl %1,%0": "=r"(page_shift):"r"(page_size)); + asm("bsrl %1,%0" : "=r" (page_shift) : "r" (page_size)); #else while (page_size > 1) { page_shift++; @@...
2017 Jun 21
2
Dovecot 2.2.30* compiling error
...on 2.2.29* with same >> options: >> RedHat based customized distro, 2.6.28.10 kernel > [...] > >> Build error: >> ltest_lib-test-bits.o: In function `bits_required64': >> /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined >> reference to `__builtin_clzll' >> /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/bits.h:33: undefined >> reference to `__builtin_clzll' >> test_lib-test-bits.o: In function `test_bits_requiredXX': >> /usr/src/redhat/BUILD/dovecot-2.2.30/src/lib/test-bits.c:74: undefined >> reference to...
2012 Jul 29
3
[LLVMdev] rotate
Nice! Clever compiler.. On 07/28/2012 08:55 PM, Michael Gottesman wrote: > I can get clang/llvm to emit a rotate instruction on x86-64 when compiling C by just using -Os and the rotate from Hacker's Delight i.e., > > ====== > #include<stdlib.h> > #include<stdint.h> > > uint32_t ror(uint32_t input, size_t rot_bits) > { > return (input>>
2020 Sep 15
0
[PATCH RFC v1 09/18] x86/hyperv: provide a bunch of helper functions
...ruct or something better for that? > + /* Allocate all the pages before disabling interrupts */ > + num_allocations = 0; > + i = 0; > + order = HV_DEPOSIT_MAX_ORDER; > + > + while (num_pages) { > + /* Find highest order we can actually allocate */ > + desired_order = 31 - __builtin_clz(num_pages); > + order = MIN(desired_order, order); > + do { > + pages[i] = alloc_pages_node(node, GFP_KERNEL, order); > + if (!pages[i]) { > + if (!order) { > + goto err_free_allocations; > + } > + --order; > + } > + } while (!pages[i]); > + &g...
2012 Mar 29
4
[GIT PULL] Assorted bugfixes and improvements (from openSUSE)
The following changes since commit b78d8e4db10e57b8d82bb82e4e3662d5dedd7255: FLAC__bitmath_ilog2,FLAC__bitmath_ilog2_wide,COUNT_ZERO_MSBS: add gcc specific optimizations (2012-03-28 15:43:48 -0300) are available in the git repository at: git://github.com/crrodriguez/flac.git master for you to fetch changes up to 3a060556772c5d6a6464afddfda7c3ad2f93a306: Remove winamp2 plugin.