RFR: 8342103: C2 compiler support for Float16 type and associated operations [v3]

Emanuel Peter epeter at openjdk.org
Tue Nov 26 07:44:45 UTC 2024


On Mon, 25 Nov 2024 20:04:09 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Hi All,
>> 
>> This patch adds C2 compiler support for various Float16 operations added by [PR#22128](https://github.com/openjdk/jdk/pull/22128)
>> 
>> Following is the summary of changes included with this patch:-
>> 
>> 1. Detection of various Float16 operations through inline expansion or pattern folding idealizations.
>> 2. Float16 operations like add, sub, mul, div, max, and min are inferred through pattern folding idealization.
>> 3. Float16 SQRT and FMA operation are inferred through inline expansion and their corresponding entry points are defined in the newly added Float16Math class.
>>       -    These intrinsics receive unwrapped short arguments encoding IEEE 754 binary16 values.
>> 5. New specialized IR nodes for Float16 operations, associated idealizations, and constant folding routines.
>> 6. New Ideal type for constant and non-constant Float16 IR nodes. Please refer to [FAQs ](https://github.com/openjdk/jdk/pull/21490#issuecomment-2482867818)for more details.
>> 7. Since Float16 uses short as its storage type, hence raw FP16 values are always loaded into general purpose register, but FP16 ISA instructions generally operate over floating point registers, therefore compiler injectes reinterpretation IR before and after Float16 operation nodes to move short value to floating point register and vice versa.
>> 8. New idealization routines to optimize redundant reinterpretation chains. HF2S + S2HF = HF
>> 6. Auto-vectorization of newly supported scalar operations.
>> 7. X86 and AARCH64 backend implementation for all supported intrinsics.
>> 9. Functional and Performance validation tests.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review comments resolution

Another example where I asked if we have good tests:
![image](https://github.com/user-attachments/assets/8fafd51e-9fed-453f-aedb-7dc6d6d17cc1)

And the test you point to is this:
![image](https://github.com/user-attachments/assets/0bfda1d7-7bc0-4e5b-8ea7-171a02a805ff)

It only covers a single constant `divisor = 8`. But what about divisors that are out of the allowed range, or not powers of 2? How do we know that you chose the bounds correctly, and are not off-by-1? And what about negative divisors?
![image](https://github.com/user-attachments/assets/8f2260e5-0075-4d34-9d30-2cec817c72f2)

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

PR Comment: https://git.openjdk.org/jdk/pull/21490#issuecomment-2499889305


More information about the hotspot-compiler-dev mailing list