RFR: 8319705: RISC-V: signumF/D intrinsics fails compiler/intrinsics/math/TestSignumIntrinsic.java [v2]
Hamlin Li
mli at openjdk.org
Thu Nov 9 09:44:21 UTC 2023
On Thu, 9 Nov 2023 01:47:33 GMT, Fei Yang <fyang at openjdk.org> wrote:
>> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
>>
>> remove rFlagsReg
>
> OK. I can now reproduce the bug with following command on sifive unmatched board:
>
> make test TEST="./test/hotspot/jtreg/compiler/intrinsics/math/TestSignumIntrinsic.java" JTREG="VM_OPTIONS=-XX:-TieredCompilation"
>
> Error message:
>
> java.lang.RuntimeException: Unexpected double result from 123.4: expected 1.0 to equal 123.4
> at jdk.test.lib.Asserts.fail(Asserts.java:634)
> at jdk.test.lib.Asserts.assertEquals(Asserts.java:205)
> at jdk.test.lib.Asserts.assertEQ(Asserts.java:178)
> at compiler.intrinsics.math.TestSignumIntrinsic.doubleTest(TestSignumIntrinsic.java:114)
> at compiler.intrinsics.math.TestSignumIntrinsic.main(TestSignumIntrinsic.java:91)
> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
> at java.base/java.lang.reflect.Method.invoke(Method.java:580)
> at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
> at java.base/java.lang.Thread.run(Thread.java:1570)
>
> JavaTest Message: Test threw exception: java.lang.RuntimeException: Unexpected double result from 123.4: expected 1.0 to equal 123.4
>
>
> But it does not always reproduce as I think it depends on C2 register allocation.
> For `C2_MacroAssembler::signum_fp`, it has three FP registers: `dst`, `src`, and `one`. And it is possible (and I have verified) that `dst` and `one` could be assigned the same FP register. This will be a problem after change [1]. This change copies `src` to `dst` on entry, thus modifies `one` in that case. This is erroneous as `one` is still alive here and will be used later by `fsgnj_d/s` when `src` is not NaN or +/-0.0.
>
> [1] https://github.com/openjdk/jdk/pull/16186/commits/867d6e8ea2a53ae71fb8fd341892e8f88347ec07
@RealFYang Thank you for exploring and sharing the information.
> src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp line 1661:
>
>> 1659: // one - gives us a floating-point 1.0 (got from matching rule)
>> 1660: // bool is_double - specifies single or double precision operations will be used.
>> 1661: void C2_MacroAssembler::signum_fp(FloatRegister dst, FloatRegister one, Register tmp, bool is_double) {
>
> I think we could still make use of scratch register `t0` in this function. That will save us one GP register.
Sure, it make sense.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16557#issuecomment-1803484278
PR Review Comment: https://git.openjdk.org/jdk/pull/16557#discussion_r1387735360
More information about the hotspot-compiler-dev
mailing list