On Wed, 23 Oct 2024 08:10:38 GMT, Jatin Bhateja <jbhat...@openjdk.org> wrote:
>> Hi all, >> This patch adds a new pass to consolidate lowering of complex >> backend-specific code patterns, such as `MacroLogicV` and the optimization >> proposed by #21244. Moving these optimizations to backend code can simplify >> shared code, while also making it easier to develop more in-depth >> optimizations. The linked bug has an example of a new optimization this >> could enable. The new phase does GVN to de-duplicate nodes and calls nodes' >> `Value()` method, but it does not call `Identity()` or `Ideal()` to avoid >> undoing any changes done during lowering. It also reuses the IGVN worklist >> to avoid needing to re-create the notification mechanism. >> >> In this PR only the skeleton code for the pass is added, moving >> `MacroLogicV` to this system will be done separately in a future patch. Tier >> 1 tests pass on my linux x64 machine. Feedback on this patch would be >> greatly appreciated! > > src/hotspot/share/opto/compile.cpp line 2466: > >> 2464: print_method(PHASE_BEFORE_LOWERING, 3); >> 2465: >> 2466: PhaseLowering lower(&igvn); > > Any specific reason to have lowering after loop optimizations ? > Lowered nodes may change the loop body size thereby impacting unrolling > decisions. Because lowering is a transformation that increases the complexity of the graph. - A `d = ExtractD(z, 4)` expanded into `x = VectorExtract(z, 2); d = ExtractD(x, 0)` increases the number of nodes by 1. - A logic cone transformed into a `MacroLogicV` introduces another kind of node that may not be recognized by other nodes. As a result, we should do this as the last step when other transformation has finished their jobs. For the concerns regarding loop body size, we still have a function in `Matcher` for that purpose. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21599#discussion_r1813233875