RFR: 8318158: RISC-V: implement roundD/roundF intrinsics [v12]
Olga Mikhaltsova
omikhaltcova at openjdk.org
Thu Dec 28 23:01:51 UTC 2023
On Fri, 22 Dec 2023 09:35:08 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> Olga Mikhaltsova has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Moved the code up + comments
>
> For normal cases, I guess `RUP` of riscv will work; but for some corner cases, we need the trick of `+0.5`, am I right?
> But all this information is just mentioned with `some inputs produce incorrect results`, which is unclear for potential readers and maintainers in the future.
> So, in the comments, can you add some information about this corner case, a simple example will definitely help here.
@Hamlin-Li No, that’s wrong: RUP of riscv won’t work, it’ll give incorrect results. Look at the rounding of some values below for example:
JAVA Math.round: src = 0.345200 dst = 0
JAVA Math.round: src = -0.555550 dst = -1
JAVA Math.round: src = -1.500000 dst = -1
JAVA Math.round: src = 1.500000 dst = 2
JAVA Math.round: src = -1.345000 dst = -1
JAVA Math.round: src = -1.450000 dst = -1
JAVA Math.round: src = -0.444460 dst = 0
JAVA Math.round: src = -0.999990 dst = -1
JAVA Math.round: src = 0.999999 dst = 1
JAVA Math.round: src = 0.000000 dst = 0
JAVA Math.round: src = 0.001000 dst = 0
JAVA Math.round: src = -0.001000 dst = 0
FCVT.W.S RUP: src = 0.345200 dst = 1
FCVT.W.S RUP: src = -0.555550 dst = 0
FCVT.W.S RUP: src = -1.500000 dst = -1
FCVT.W.S RUP: src = 1.500000 dst = 2
FCVT.W.S RUP: src = -1.345000 dst = -1
FCVT.W.S RUP: src = -1.450000 dst = -1
FCVT.W.S RUP: src = -0.444460 dst = 0
FCVT.W.S RUP: src = -0.999990 dst = 0
FCVT.W.S RUP: src = 0.999990 dst = 1
FCVT.W.S RUP: src = 0.000000 dst = 0
FCVT.W.S RUP: src = 0.001000 dst = 1
FCVT.W.S RUP: src = -0.001000 dst = 0
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16382#issuecomment-1871612334
More information about the hotspot-dev
mailing list