RFR: 8279508: Auto-vectorize Math.round API [v2]
Joseph D. Darcy
joe.darcy at oracle.com
Wed Feb 16 22:20:20 UTC 2022
On 2/12/2022 6:55 PM, Jatin Bhateja wrote:
> On Fri, 21 Jan 2022 00:49:04 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:
>
>> The JVM currently initializes the x86 mxcsr to round to nearest even, see below in stubGenerator_x86_64.cpp: // Round to nearest (even), 64-bit mode, exceptions masked StubRoutines::x86::_mxcsr_std = 0x1F80; The above works for Math.rint which is specified to be round to nearest even. Please see: https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html : section 4.8.4
>>
>> The rounding mode needed for Math.round is round to positive infinity which needs a different x86 mxcsr initialization(0x5F80).
> Hi @sviswa7 ,
> As per JLS 17 section 15.4 Java follows round to nearest rounding policy for all floating point operations except conversion to integer and remainder where it uses round toward zero.
That is a true background condition, but I will note that the Math.round
method does independently define the semantics of its operation and
rounding behavior, which has changed (slightly) over the lifetime of the
platform.
-Joe
More information about the core-libs-dev
mailing list