RFR: 8372978: [VectorAPI] Fix incorrect identity values in UMIN/UMAX reductions
Quan Anh Mai
qamai at openjdk.org
Tue Dec 9 07:13:54 UTC 2025
On Tue, 9 Dec 2025 07:07:04 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]);
>> }
>
> Hi @merykitty , I feel it's better to start the reduction operation from `the identity value`, because `firstNonZero`, `min/max`, and `umin/umax` all reuse the same template function `gen_reduction_op_func`. If we start from `a[idx]` for `umin/umax` (`min/max` is also possible), then we have to create a new template function. Considering we've already correctly fixed this issue, I think the current approach might be more maintainable. What do you think?
@erifan I don't see why `firstNonZero` cannot do the same and start from `a[idx]` here?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28692#discussion_r2601379419
More information about the core-libs-dev
mailing list