lkml.org 
[lkml]   [1998]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: The Kommunity vs. Dick Johnson
> Also at last check, GCC doesn't know how to handle data-dependent
> rotates. i.e,
>
> extern inline __u32 rotate_left(int i, __u32 word)
> {
> return (word << i) | (word >> (32 - i));
>
> }
>
> should compile to this:
>
> extern inline __u32 rotate_left(int i, __u32 word)
> {
> __asm__("roll %%cl,%0"
> :"=r" (word)
> :"0" (word),"c" (i));
> return word;
> }
>

check again :-)

max:~$ cat rot.c
extern unsigned int rotate_left(int i, unsigned int word)
{
return (word << i) | (word >> (32 - i));
}
max:~$ egcs -S -O2 -fomit-frame-pointer rot.c
max:~$ cat rot.s
.file "rot.c"
.version "01.01"
/ GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release) (i386-redhat-linux) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release).
/ options passed: -O2 -fomit-frame-pointer
/ options enabled: -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
/ -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
/ -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse -finline
/ -fkeep-static-consts -fcaller-saves -fpcc-struct-return
/ -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns2 -fcommon
/ -fverbose-asm -fgnu-linker -fregmove -falias-check -fargument-alias
/ -m80387 -mhard-float -mno-soft-float -mieee-fp -mfp-ret-in-387
/ -mschedule-prologue -mcpu=i386 -march=pentium

gcc2_compiled.:
.text
.align 4
.globl rotate_left
.type rotate_left,@function
rotate_left:
movl 4(%esp),%ecx
movl 8(%esp),%eax
roll %cl,%eax
ret
.Lfe1:
.size rotate_left,.Lfe1-rotate_left
.ident "GCC: (GNU) egcs-2.90.29 980515 (egcs-1.0.3 release)"
max:~$

--
Robert Wilhelm

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.102 / U:1.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site