RFR: 8238669: Long.divideUnsigned is extremely slow for certain values (Needs to be Intrinsic)

Éamonn McManus github.com+5246810+eamonnmcmanus at openjdk.java.net
Tue Sep 8 20:24:51 UTC 2020


On Sun, 6 Sep 2020 15:25:10 GMT, rgiulietti <github.com+70726043+rgiulietti at openjdk.org> wrote:

> This is a follow-up of the Mercurial-based workflow initiated on the core-lib-devs mailing list [0]. Not sure if this
> one is strictly necessary or if the patches sent on the list are sufficient. Anyway, I exploit this PR as a test ;-)
> [0] https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-September/068474.html

src/java.base/share/classes/java/lang/Long.java line 1675:

> 1673:             final long q = (dividend >>> 1) / divisor << 1;
> 1674:             final long r = dividend - q * divisor;
> 1675:             return q + ((r | ~(r - divisor)) >>> Long.SIZE - 1);

I think it would be worth parenthesizing the right hand size of the `>>>` operator here too.

src/java.base/share/classes/java/lang/Long.java line 1677:

> 1675:             return q + ((r | ~(r - divisor)) >>> Long.SIZE - 1);
> 1676:         }
> 1677:         return (dividend & ~(dividend - divisor)) >>> Long.SIZE - 1;

Parenthesize RHS?

-------------

PR: https://git.openjdk.java.net/jdk/pull/31


More information about the core-libs-dev mailing list