RFR: 8360116: Add support for AVX10 floating point minmax instruction
Jatin Bhateja
jbhateja at openjdk.org
Wed Jun 25 10:35:08 UTC 2025
Intel@ AVX10 ISA [1] extensions added new floating point MIN/MAX instructions which comply with definitions in IEEE-754-2019 standard section 9.6 and can directly emulate Math.min/max semantics without the need for any special handling for NaN, +0.0 or -0.0 detection.
**The following pseudo-code describes the existing algorithm for min/max[FD]:**
Move the non-negative value to the second operand; this will ensure that we correctly handle 0.0 and -0.0 values, if values being compared are both 0.0s (of either sign), the value in the second operand (source operand) is returned. Existing MINPS and MAXPS semantics only check for NaN as the second operand; hence, we need special handling to check for NaN at the first operand.
btmp = (b < +0.0) ? a : b
atmp = (b < +0.0) ? b : a
Tmp = Max_Float(atmp , btmp)
Res = (atmp == NaN) ? atmp : Tmp
For min[FD] we need a small tweak in the above algorithm, i.e., move the non-negative value to the first operand, this will ensure that we correctly select -0.0 if both the operands being compared are 0.0 or -0.0.
btmp = (b < +0.0) ? b : a
atmp = (b < +0.0) ? a : b
Tmp = Max_Float(atmp , btmp)
Res = (atmp == NaN) ? atmp : Tmp
Thus, we need additional special handling for NaNs and +/-0.0 to compute floating-point min/max values to comply with the semantics of Math.max/min APIs using existing MINPS / MAXPS instructions. AVX10.2 added a new instruction, VPMINMAX[SH,SS,SD]/[PH,PS,PD], which comprehensively handles special cases, thereby eliminating the need for special handling.
Patch emits new instructions for reduction and non-reduction operations for single, double, and Float16 type.
Kindly review and share your feedback.
Best Regards,
Jatin
[1] https://www.intel.com/content/www/us/en/content-details/856721/intel-advanced-vector-extensions-10-2-intel-avx10-2-architecture-specification.html?wapkw=AVX10
-------------
Commit messages:
- Extending the patch to cover reduction operations
- 8360116: Add support for AVX10 floating point minmax instruction
Changes: https://git.openjdk.org/jdk/pull/25914/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25914&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8360116
Stats: 420 lines in 7 files changed: 379 ins; 4 del; 37 mod
Patch: https://git.openjdk.org/jdk/pull/25914.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25914/head:pull/25914
PR: https://git.openjdk.org/jdk/pull/25914
More information about the hotspot-dev
mailing list