RFR: 8372978: [VectorAPI] Fix incorrect identity values in UMIN/UMAX reductions [v2]
Eric Fang
erfang at openjdk.org
Fri Dec 12 08:42:22 UTC 2025
> The original implementation of UMIN/UMAX reductions in JDK-8346174 used incorrect identity values in the Java implementation and test code.
>
> Problem:
> --------
> UMIN was using MAX_OR_INF (signed maximum value) as the identity:
> - Byte.MAX_VALUE (127) instead of max unsigned byte (255)
> - Short.MAX_VALUE (32767) instead of max unsigned short (65535)
> - Integer.MAX_VALUE instead of max unsigned int (-1)
> - Long.MAX_VALUE instead of max unsigned long (-1)
>
> UMAX was using MIN_OR_INF (signed minimum value) as the identity:
> - Byte.MIN_VALUE (-128) instead of 0
> - Short.MIN_VALUE (-32768) instead of 0
> - Integer.MIN_VALUE instead of 0
> - Long.MIN_VALUE instead of 0
>
> This caused incorrect result. For example:
> UMAX([42,42,...,42]) returned 128 instead of 42
>
> Solution:
> ---------
> Use correct unsigned identity values:
> - UMIN: ($type$)-1 (maximum unsigned value)
> - UMAX: ($type$)0 (minimum unsigned value)
>
> Changes:
> --------
> - X-Vector.java.template: Fixed identity values in reductionOperations
> - gen-template.sh: Fixed identity values for test code generation
> - templates/Unit-header.template: Updated copyright year to 2025
> - Regenerated all Vector classes and test files
>
> Testing:
> --------
> All types (byte/short/int/long) now return correct results in both interpreter mode (-Xint) and compiled mode.
Eric Fang 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:
- Declare two constants for UMIN/UMAX reduction identity values
- Merge branch 'master' into JDK-8372978-fix-umin-umax-identity
- 8372978: [VectorAPI] Fix incorrect identity values in UMIN/UMAX reductions
The original implementation of UMIN/UMAX reductions in JDK-8346174
used incorrect identity values in the Java implementation and test code.
Problem:
--------
UMIN was using MAX_OR_INF (signed maximum value) as the identity:
- Byte.MAX_VALUE (127) instead of max unsigned byte (255)
- Short.MAX_VALUE (32767) instead of max unsigned short (65535)
- Integer.MAX_VALUE instead of max unsigned int (-1)
- Long.MAX_VALUE instead of max unsigned long (-1)
UMAX was using MIN_OR_INF (signed minimum value) as the identity:
- Byte.MIN_VALUE (-128) instead of 0
- Short.MIN_VALUE (-32768) instead of 0
- Integer.MIN_VALUE instead of 0
- Long.MIN_VALUE instead of 0
This caused incorrect result. For example:
UMAX([42,42,...,42]) returned 128 instead of 42
Solution:
---------
Use correct unsigned identity values:
- UMIN: ($type$)-1 (maximum unsigned value)
- UMAX: ($type$)0 (minimum unsigned value)
Changes:
--------
- X-Vector.java.template: Fixed identity values in reductionOperations
- gen-template.sh: Fixed identity values for test code generation
- templates/Unit-header.template: Updated copyright year to 2025
- Regenerated all Vector classes and test files
Testing:
--------
All types (byte/short/int/long) now return correct results in both
interpreter mode (-Xint) and compiled mode.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28692/files
- new: https://git.openjdk.org/jdk/pull/28692/files/4fb63a36..7f737457
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28692&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28692&range=00-01
Stats: 47492 lines in 706 files changed: 27364 ins; 15029 del; 5099 mod
Patch: https://git.openjdk.org/jdk/pull/28692.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28692/head:pull/28692
PR: https://git.openjdk.org/jdk/pull/28692
More information about the core-libs-dev
mailing list