On Sep 6, 2011, at 11:19 PM, Ron Wilson wrote:
> 
> The asm() calls are being used to invoke the rotate instructions. C
> does not have operators for peforming bitwise rotation of an operand
> and emulating a rotate using shifts is messy and very ineficient:
> 
> unsigned int rotateLeft(unsigned int x, unsigned int n)
> {
>    unsigned int t;
> 
>    t = x >> (SIZEOFINT - n);
>    return ((x << n) | t);
> }

FYI,

$ gcc -O2 -S rotate.c
$ cat rotate.s
…
_rotateLeft:
Leh_func_begin1:
        pushq   %rbp
Ltmp0:
        movq    %rsp, %rbp
Ltmp1:
        movb    %sil, %cl
        movl    %edi, %eax
        roll    %cl, %eax
        popq    %rbp
        ret
Leh_func_end1:
..

$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) 
(LLVM build 2335.15.00)

(This is GCC with LLVM backend (default on OS X Lion)).

--
Dmitry Chestnykh

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to