RFR: 8302673: [SuperWord] MaxReduction and MinReduction should vectorize for int [v4]
Vladimir Kozlov
kvn at openjdk.org
Fri Jun 2 16:45:17 UTC 2023
On Fri, 2 Jun 2023 12:27:33 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:
>> 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)`:
>>
>> 
>>
>> Here is an example of the two permutations handled in step 2 with `x = RShiftI`, `c0 = 10` or `11`, and `c1 = 11` or `10`:
>>
>> 
>>
>> 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 pull request now contains 30 commits:
>
> - Re-apply extraction of min/max building after JDK-8309295
> - Merge branch 'master' into JDK-8302673
> - Abort idealization if any of the adds has a TOP input
> - Revert extraction of min/max building
> - Complete test battery with remaining no-add cases
> - Handle case without inner additions by restoring 'as_add_with_constant' to its previous state
> - Add tests to exercise the case without inner additions
> - Extract MinI/MaxI construction; pass around ConstAddOperands instead of individual components
> - Merge branch 'master' into JDK-8302673
> - Defer op(x, x) to constant/identity propagation early
> - ... and 20 more: https://git.openjdk.org/jdk/compare/7b0a3360...cfcc16fd
Update is good.
-------------
Marked as reviewed by kvn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13924#pullrequestreview-1457997987
More information about the hotspot-compiler-dev
mailing list