RFR: 8287087: C2: perform SLP reduction analysis on-demand [v2]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Wed Apr 5 09:16:19 UTC 2023


On Sun, 2 Apr 2023 05:52:17 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> src/hotspot/share/opto/superword.cpp line 504:
>> 
>>> 502:       // to the phi node following edge index 'input'.
>>> 503:       PathEnd path =
>>> 504:         find_in_path(
>> 
>> Hi @robcasloz,
>> find_in_path expects reduction nodes to be present at same edge indices in the reduction chain, it also honors has_swapped_edge flag during backward traversal.
>> However, there are still some ideal transforms like following which may break the reduction chain and this will prevent Min/Max reductions for test case mentioned in JDK-8302673.
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/addnode.cpp#L1147
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/addnode.cpp#L1230
>
> One way to add fault-tolerance to find_in_path could be to follow strict DFS semantics where an alternate path is taken if node's predicates are not satisfied, currently we are starting all over again from the first node of chain with a different reduction_input which prevents inferring reduction chain even though all the nodes in the chain are commutative isomorphic operations.

Thanks for the observation and the suggestion! This changeset proposes swapped edge tracking for efficiency and better worst-case behavior of the analysis, but as you observe this is done at the expense of robustness. I will investigate whether the swapped edge tracking approach can be extended to deal with the `MinI`/`MaxI` transformations that you mention. If not, I will re-consider using a generic search approach like you and @eme64 suggest.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13120#discussion_r1158247329


More information about the hotspot-compiler-dev mailing list