Java 8 Integer and Long unsigned methods - are there plans to add intrinsics for them?

Roman Leventov leventov at ya.ru
Fri Apr 11 12:58:16 UTC 2014


No, the code for x86 is the same. But long division is almost twice slower than int on AMD.

IMO the worth of having unsigned helpers in standard lib is mainly in ability of achiving native performance (exactly equal to performance of builtin signed division). Because it isn't bothering to add these one-liners to own adhoc.util.Math class, keeping compatibility with Java 7.

11.04.14, 15:52, "Andrew Haley" <aph at redhat.com>":
> 
> On 04/11/2014 12:54 AM, Roman Leventov wrote:
> >  > 11.04.2014, 02:51, "Christian Thalinger" <christian.thalinger at oracle.com>:
> >  > Do you see a performance problem with these methods?
> > Currently divideUnsigned and remainderUnsigned take a dozen of instructions with 
> > widening to long, while there is a signle div assembly instruction for this.
> 
> It seems this is an x86 thing rather than a HotSpot thing.  On AArch64
> I get
> 
> 01c     ubfm  R10, R2, 0, 31    # ui2l
> 020     ubfm  R11, R1, 0, 31    # ui2l
> 024     cbeq   R10, B4  P=0.000001 C=-1.000000
> 028     sdiv   R10, R11, R10
> 
> This isn't exactly ideal, given that long division is slower than int
> division, but it's not terrible.
> 
> I can't match on
> 
> (Set dst (DivL (AndL (ConvI2L src1) mask) (AndL (ConvI2L src2) mask1)))
> 
> and generate a simple udiv because of the pesky (If ...) that checks for
> division by zero.  I suppose we could persuade HotSpot to rearrange things.
> 
> Andrew.
> 


-- 
Отправлено из мобильной Яндекс.Почты: http://m.ya.ru/ymail


More information about the hotspot-compiler-dev mailing list