RFR: 8302673: [SuperWord] MaxReduction and MinReduction should vectorize for int [v2]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Wed May 31 07:14:18 UTC 2023


> The canonicalization of MinI/MaxI chains into right-spline graphs within `MinINode/MaxINode::Ideal()` inhibits the vectorization of reductions of these nodes. This changeset reworks `MinINode/MaxINode::Ideal()` to perform the same algebraic optimizations without the need for canonicalization, re-enabling auto-vectorization of MinI/MaxI reductions. This is achieved by handling all four permutations of the targeted Ideal subgraph induced by the commutativity of MinI/MaxI directly. The algorithm (for the MaxI case, the MinI case is analogous) tries to apply two Ideal graph rewrites in the following order, where `c0` and `c1` are constants and `MAX` is a compile-time operation:
> 1. `max(x + c0, max(x + c1, z))` (or a permutation of it) to `max(x + MAX(c0, c1), z)`.
> 2. `max(x + c0, x + c1)` (or a permutation of it) to `x + MAX(c0, c1)`.
> 
> Here is an example of the four permutations handled in step 1 with `x = RShiftI`, `c0 = 100` or `150`, `c1 = 150` or `100`, and `z = ConI (#int:200)`:
> 
> ![two-level-idealization](https://github.com/openjdk/jdk/assets/8792647/bf60a2c3-39cd-4f0d-965d-c711723e374c)
> 
> Here is an example of the two permutations handled in step 2 with `x = RShiftI`, `c0 = 10` or `11`, and `c1 = 11` or `10`:
> 
> ![one-level-idealization](https://github.com/openjdk/jdk/assets/8792647/0a1fe85b-3f30-46bc-8817-d90b3eff946c)
> 
> The changeset implements `MinINode/MaxINode::Ideal()` in a common method `MaxNode::IdealI()`, since the algorithm is symmetric for both node types. The changeset also extends the existing MinI/MaxI Idealization tests with positive tests for all targeted permutations and negative tests, and adds a new test (contributed by @jbhateja) to assert that MinI/MaxI reductions are vectorized.
> 
> #### Testing
> 
> ##### Functionality
> 
> - tier1-5, stress test, fuzzing (windows-x64, linux-x64, linux-aarch64, macosx-x64, macosx-aarch64; release and debug mode).
> 
> ##### Performance
> 
> - Tested performance on a set of standard benchmark suites (DaCapo, SPECjbb2015, SPECjvm2008). No significant change was observed.

Roberto Castañeda Lozano 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 22 additional commits since the last revision:

 - Merge branch 'master' into JDK-8302673
 - Defer op(x, x) to constant/identity propagation early
 - Merge branch 'master' into JDK-8302673
 - Refactor idealization and extracted Identity transformation for clarity
 - Make auxiliary add operand extraction function return a tuple
 - Randomize array values in min/max test computation
 - Merge branch 'master' into JDK-8302673
 - Merge branch 'master' into JDK-8302673
 - Refine comments
 - Update copyright header
 - ... and 12 more: https://git.openjdk.org/jdk/compare/acde5e39...a6db3cc4

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/13924/files
  - new: https://git.openjdk.org/jdk/pull/13924/files/9fd482b5..a6db3cc4

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=13924&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13924&range=00-01

  Stats: 134197 lines in 2266 files changed: 102246 ins; 15645 del; 16306 mod
  Patch: https://git.openjdk.org/jdk/pull/13924.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13924/head:pull/13924

PR: https://git.openjdk.org/jdk/pull/13924


More information about the hotspot-compiler-dev mailing list