RFR: 8338021: Support saturating vector operators in VectorAPI [v2]
Jasmine Karthikeyan
jkarthikeyan at openjdk.org
Fri Aug 9 03:31:38 UTC 2024
On Thu, 8 Aug 2024 17:20:06 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> Hi All,
>>
>> As per the discussion on panama-dev mailing list[1], patch adds the support following new vector operators.
>>
>>
>> . SATURATING_UADD : Saturating unsigned addition.
>> . SATURATING_ADD : Saturating signed addition.
>> . SATURATING_USUB : Saturating unsigned subtraction.
>> . SATURATING_SUB : Saturating signed subtraction.
>> . UMAX : Unsigned max
>> . UMIN : Unsigned min.
>>
>>
>> New vector operators are applicable to only integral types since their values wraparound in over/underflowing scenarios after setting appropriate status flags. For floating point types, as per IEEE 754 specs there are multiple schemes to handler underflow, one of them is gradual underflow which transitions the value to subnormal range. Similarly, overflow implicitly saturates the floating-point value to an Infinite value.
>>
>> As the name suggests, these are saturating operations, i.e. the result of the computation is strictly capped by lower and upper bounds of the result type and is not wrapped around in underflowing or overflowing scenarios.
>>
>> Summary of changes:
>> - Java side implementation of new vector operators.
>> - Add new scalar saturating APIs for each of the above saturating vector operator in corresponding primitive box classes, fallback implementation of vector operators is based over it.
>> - C2 compiler IR and inline expander changes.
>> - Optimized x86 backend implementation for new vector operators and their predicated counterparts.
>> - Extends existing VectorAPI Jtreg test suite to cover new operations.
>>
>> Kindly review and share your feedback.
>>
>> Best Regards,
>> PS: Intrinsification and auto-vectorization of new core-lib API will be addressed separately in a follow-up patch.
>>
>> [1] https://mail.openjdk.org/pipermail/panama-dev/2024-May/020408.html
>
> Jatin Bhateja has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8338201
> - Removed redundant comment
> - 8338021: Support saturating vector operators in VectorAPI
src/hotspot/share/opto/type.cpp line 495:
> 493: TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
> 494: TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
> 495: TypeInt::UINT = TypeInt::make(0, max_juint, WidenMin); // Unsigned ints
This would make an illegal type, right? Since `TypeInt` is signed using `max_juint` as the hi value would end up as signed -1, resulting in the type `0..-1`, an empty type. I wonder if there's a better way to handle this, since in the type system empty types are in a sense equivalent to `TOP`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1710642379
More information about the core-libs-dev
mailing list