[PATCH, i386]: Generate xlat insn

Chris Lattner clattner@apple.com
Tue Sep 25 07:25:00 GMT 2007


On Sep 24, 2007, at 1:50 AM, Uros Bizjak wrote:

> Hello!
>
> This small patch implements xlat insn. With attached patch,  
> following testcase:
>
> --cut here--
> const unsigned char *table;
>
> char test(unsigned char index)
> {
>   return table[index];
> }
> --cut here--
>
> compiles into:
>
> test:
>         pushl   %ebx
>         movl    table, %ebx
>         movzbl  8(%esp), %eax
>         xlat
>         popl    %ebx
>         ret
>
> instead of:
>
> test:
>         movzbl  4(%esp), %eax
>         movl    table, %edx
>         movzbl  (%edx,%eax), %eax
>         ret
>
> Some remarks about the patch:

Out of curiosity, why do this at all?  Your example above doesn't  
make a compelling case for a size win here, and xlat seems like it  
would always be slower than the equivalent load.  Is there a recent  
x86 implementation where your first asm is faster than the second chunk?

-Chris



More information about the Gcc-patches mailing list