Displaying 4 results from an estimated 4 matches for "__builtin_rotl".
2012 Jul 29
3
[LLVMdev] rotate
...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 in code relating to hashing and cryptology. I know that
the compiler *should* optimise
uint32_t ror(uint32_t input, size_t rot_bits) {
return (input >> rot_bits) | (input <<...
2012 Jul 29
0
[LLVMdev] rotate
...since LCS fits in nicely with the other shift operators. But, it is quite
cumbersome to merge :*(. I would be happy to resend the original patch if
you'd like.
-Cameron
On Sun, Jul 29, 2012 at 4:02 PM, Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:
...
> It would be nice to have a __builtin_rotl family in clang, in
> my opinion, but it would need back-end support from llvm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120729/6a1f68df/attachment.html>
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
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>>