RFR: 8323220: Reassociate loop invariants involved in Cmps and Add/Subs [v15]
Christian Hagedorn
chagedorn at openjdk.org
Mon Apr 8 06:36:14 UTC 2024
On Fri, 5 Apr 2024 17:36:46 GMT, Joshua Cao <duke at openjdk.org> wrote:
>> // inv1 == (x + inv2) => ( inv1 - inv2 ) == x
>> // inv1 == (x - inv2) => ( inv1 + inv2 ) == x
>> // inv1 == (inv2 - x) => (-inv1 + inv2 ) == x
>>
>>
>> For example,
>>
>>
>> fn(inv1, inv2)
>> while(...)
>> x = foobar()
>> if inv1 == x + inv2
>> blackhole()
>>
>>
>> We can transform this into
>>
>>
>> fn(inv1, inv2)
>> t = inv1 - inv2
>> while(...)
>> x = foobar()
>> if t == x
>> blackhole()
>>
>>
>> Here is an example: https://github.com/openjdk/jdk/blob/b78896b9aafcb15f453eaed6e154a5461581407b/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java#L910. LHS `1` and RHS `pos` are both loop invariant
>>
>> Passes tier1 locally on Linux machine. Passes GHA on my fork.
>
> Joshua Cao has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 24 additional commits since the last revision:
>
> - Fix typo
> - Formatting, use @run driver, remove legacy header comments
> - Merge remote-tracking branch 'josh/licm' into licm
> - Merge branch 'master' into licm
> - @run driver -> @run main
> - Add tests for add/sub reassociation
> - Merge branch 'master' into licm
> - Merge branch 'master' into licm
> - Merge branch 'master' into licm
> - Merge branch 'master' into licm
> - ... and 14 more: https://git.openjdk.org/jdk/compare/7ab2c08f...1b27aae4
Thanks for making the changes. One more minor thing, otherwise, looks good!
src/hotspot/share/opto/loopTransform.cpp line 277:
> 275: }
> 276: for (DUIterator i = n->outs(); n->has_out(i); i++) {
> 277: BoolNode *bool_out = n->out(i)->isa_Bool();
Suggestion:
BoolNode* bool_out = n->out(i)->isa_Bool();
-------------
Marked as reviewed by chagedorn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17375#pullrequestreview-1985540351
PR Review Comment: https://git.openjdk.org/jdk/pull/17375#discussion_r1555286670
More information about the hotspot-compiler-dev
mailing list