RFR: 8361037: [ubsan] compiler/c2/irTests/TestFloat16ScalarOperations division by 0 [v2]

Jatin Bhateja jbhateja at openjdk.org
Tue Jul 1 13:28:22 UTC 2025


On Tue, 1 Jul 2025 11:19:04 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:

>> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Review comments resolution
>
> src/hotspot/share/opto/divnode.cpp line 833:
> 
>> 831:     }
>> 832: 
>> 833:     if (g_isfinite(t1->getf()) && t2->getf() == 0.0) {
> 
> Is the `g_isfinite` for `t1` really needed? If the dividend is infinite then the result is also an infinity with the appropriate sign. Does this not result in `INF / 0.0` being calculated below? This would also be undefined by the C++ standard, would it not? Since as far as I know not all s390 models implement IEEE754, perhaps it would be better to remove the `g_isfinite` to prevent the native `INF / 0.0` below.

As per C++ standard section 7.6.5 (expr.mul), behavior is undefined only if the second operand is 0.0.
In all other situations, we can expect a standard-compliant C++ compiler to generate code following IEEE 754 semantics, irrespective of target floating point model, but Java semantics expect to return a NaN value if either of the operands is a NaN.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26062#discussion_r2177604366


More information about the hotspot-compiler-dev mailing list