RFR: 8356281: Fix for TestFPComparison failure due to incorrect result [v3]

Jatin Bhateja jbhateja at openjdk.org
Wed May 14 11:37:53 UTC 2025


On Mon, 12 May 2025 22:46:10 GMT, Srinivas Vamsi Parasa <sparasa at openjdk.org> wrote:

>> This PR fixes the cause of failure in TestFPComparison while using APX NDD instructions.
>> 
>> The test passes after using this fix as shown below:
>> 
>> Passed: compiler/c2/irTests/TestFPComparison.java
>> Test results: passed: 1
>> 
>> 
>> ==============================
>> Test summary
>> ==============================
>>    TEST                                              TOTAL  PASS  FAIL ERROR  SKIP   
>>    jtreg:test/hotspot/jtreg/compiler/c2/irTests/TestFPComparison.java
>>                                                          1     1     0     0     0   
>> ==============================
>> TEST SUCCESS
>
> Srinivas Vamsi Parasa has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add TEMP(dst)

Fix looks good to me.

src/hotspot/cpu/x86/x86_64.ad line 6597:

> 6595:   ins_encode %{
> 6596:     __ ecmovq(Assembler::parity, $dst$$Register, $src1$$Register, $src2$$Register);
> 6597:     __ cmovq(Assembler::notEqual, $dst$$Register, $src2$$Register);

FTR, 
Instruction sequence for NaN-APX:-
 
CMOVE DST , SRC if FLAG is PF
CMOVE DST , SRC if FLAG is NE
 
With APX

CMOVE DST, DEF_DST, SRC if FLAG is PF
CMOVE DST, DEF_DST, SRC if FLAT is NE

Root cause:
So in back-to-back CMOVEs we end up updating the DST with DEF_DST if ZF is set since NE is false and not retain the DST value updated by prior CMOVE, this is not the case with Non-APX case since second DST is not executed is ZF is set and DST retains the value set by prior CMOVE.

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

Marked as reviewed by jbhateja (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25101#pullrequestreview-2839832657
PR Review Comment: https://git.openjdk.org/jdk/pull/25101#discussion_r2088726274


More information about the hotspot-compiler-dev mailing list