RFR: 8323220: Reassociate loop invariants involved in Cmps and Add/Subs

Joshua Cao duke at openjdk.org
Wed Jan 17 19:30:51 UTC 2024


On Tue, 16 Jan 2024 17:51:58 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Yeah, it would work for this patch. But people working on future unrelated changes may have to change the line number. Seems more pain than its worth.
>
> Another suboptimal idea: you wrap the add / sub in a method, and then ensure that this method is inlined. It might still keep the annotation of being part of that inner method, and you could use regex to check for it.
> 
> Or maybe we could also have some sort of relative line offset mechanism in the IR framework, that allows you to specify that you want something that is let's say 7 lines down from the IR rule.

Some sort of pattern matcher could work. It would be able nice to match something like `a ADD_I b CMP_LT c`. In java this could look something like 


@IR(counts = {IRNode.CMP_LT[IRNode.ANY, IRNode.SUB_I, IRNode.ANY], "1"}


The arguments in the `[]` are the inputs. `IRNode.ANY` matches any node. (The zero'th node is ANY because its the region node).

Anyway, I think a `lt` test is not super-required for the coverage for this PR. The current machinery does not provide a convenient way to test it. I'd prefer to avoid something hacky. I think this work can be done separately.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17375#discussion_r1456368613


More information about the hotspot-compiler-dev mailing list