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

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Tue Apr 25 12:02:12 UTC 2023


On Mon, 24 Apr 2023 11:59:45 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> I tried out your suggestion but unfortunately, the bookkeeping code (marking/storing candidate nodes and their predecessors in the tentative reduction chain) became more complex than the simplifications it enabled.
>
>> I tried out your suggestion but unfortunately, the bookkeeping code (marking/storing candidate nodes and their predecessors in the tentative reduction chain) became more complex than the simplifications it enabled.
> 
> Hi @robcasloz ,  Ok, my concern was that post path detection we have two occurrences of _original_input_ , this can be optimized if we bookkeep node encountered during path detection. Kindly consider attached rough patch which records the nodes during patch detection.  
> [reduction_patch.txt](https://github.com/openjdk/jdk/files/11310121/reduction_patch.txt)

Thanks for the patch, it is very similar to what I had tried before (see my comment above), except your patch rejects reduction chains with external users, whereas this PR allows reduction chain nodes to be used as long as the user is not within the loop. This follows the original logic more closely (although I have not found a case where the distinction matters yet):

https://github.com/openjdk/jdk/blob/a4a5385831b58e66fe3f34cef618643f9be68c9e/src/hotspot/share/opto/loopTransform.cpp#L2539-L2549)

To ease comparison, I adapted your patch to perform the same test as this PR. Here is the result:

https://github.com/robcasloz/jdk/compare/JDK-8287087...robcasloz:jdk:JDK-8287087-single-original-input-call

In my opinion, even if the patch gets rid of the last reduction path traversal, the result is not necessarily more readable or efficient, due to the cognitive and computational overhead of introducing an auxiliary `GrowableArray` data structure.

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

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


More information about the hotspot-compiler-dev mailing list