RFR: 8372978: [VectorAPI] Fix incorrect identity values in UMIN/UMAX reductions
Paul Sandoz
psandoz at openjdk.org
Mon Dec 8 23:31:57 UTC 2025
On Mon, 8 Dec 2025 05:56:16 GMT, Eric Fang <erfang at openjdk.org> wrote:
>> No, the starting value is `-1`, this test depends on the fact that we choose the correct identity value for this particular operation as the starting value, which this issue is about. As a result, it would be better to write the test so that we do not depend on the identity value.
>>
>> byte res = a[idx];
>> for (int i = idx + 1; i < (idx + SPECIES.length()); i++) {
>> res = (byte) VectorMath.minUnsigned(res, a[i]);
>> }
>
> Okay, I got your point. I think this might be to maintain consistency with `UMINReduceMasked`; for the masked version, if no element is selected, it returns the identity value. I'm okay with both approaches, maybe let’s hear what @PaulSandoz thinks.
For masking we need to start with the identity or otherwise use the identify when no mask bits are set. It would be better to declare as constants and refer to them e.g., `UMAX_VALUE`, `UMIN_VALUE`. There are also other cases where we use identity values for reduction and they follow the same pattern of declaration and use.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28692#discussion_r2600503579
More information about the core-libs-dev
mailing list