Short/Character.reverseBytes intrinsics

Christian Thalinger Christian.Thalinger at Sun.COM
Thu Apr 15 05:45:16 PDT 2010


On Tue, 2010-04-13 at 22:50 +0200, Ulf Zibis wrote:
> +1
> I would like to see this enhancement.
> 
> But we could do better on x86, as I guess those swap instructions would 
> likely come accompanied with a move:
>    0x00b95d79: bswap  %ebx               ;*invokevirtual putInt
>    ...
>    0x00b95d8d: mov    %ebx,(%eax,%ecx,1)  ;*invokevirtual putInt
> 
> could be shorter:
>    ...
>    0x00b95d8b: movbe    %ebx,(%eax,%ecx,1)  ;*invokevirtual putInt
> 
> On char/short there could be an additional win:
> swap(x) { return (char)(Integer.reverseBytes(x) >>> 16); }:
>    0x00b8965d: bswap  %edx
>    0x00b8965f: shr    $0x10,%edx
>    ...
>    0x00b8966c: mov    %dx,(%eax)         ;*invokevirtual putChar
>                                          ; - 
> java.nio.DirectByteBuffer::putChar at 30 (line 482)
> 
> ... but best would be:
>    0x00b89667: movbe    %dx,(%eax)         ;*invokevirtual putChar
>                                          ; - 
> java.nio.DirectByteBuffer::putChar at 30 (line 482)
> 
> Same thoughts on getInt, getChar/Short.
> On SPARC I don't know.

I filed:

6944091: C2 should use movbe on x86 if available

-- Christian



More information about the hotspot-compiler-dev mailing list