RFR: 8323220: Reassociate loop invariants involved in Cmps and Add/Subs [v12]
Emanuel Peter
epeter at openjdk.org
Thu Mar 21 12:02:27 UTC 2024
On Thu, 21 Mar 2024 05:35:43 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 15 additional commits since the last revision:
>
> - Add tests for add/sub reassociation
> - Merge branch 'master' into licm
> - Make inputs deterministic. Make size an arg. Fix comments. Formatting.
> - Update test to utilize @setup method for arguments
> - Merge branch 'master' into licm
> - Add correctness test for some random tests with random inputs
> - Add some correctness tests where we do reassociate
> - Remove unused TestInfo parameter. Have some tests exit mid-loop.
> - Merge branch 'master' into licm
> - Small fixes and add check methods for tests
> - ... and 5 more: https://git.openjdk.org/jdk/compare/d6e69638...b151293d
Just two little details, then we should be ready!
Ping me once you updated it, and I will run our internal testing one more time before approving!
test/hotspot/jtreg/compiler/loopopts/InvariantCodeMotionReassociateAddSub.java line 36:
> 34: * @summary Test loop invariant code motion of add/sub through reassociation
> 35: * @library /test/lib /
> 36: * @run driver compiler.c2.loopopts.InvariantCodeMotionReassociateAddSub
Suggestion:
* @run main compiler.c2.loopopts.InvariantCodeMotionReassociateAddSub
Otherwise external flags are not passed in.
test/hotspot/jtreg/compiler/loopopts/InvariantCodeMotionReassociateCmp.java line 36:
> 34: * @summary Test loop invariant code motion for cmp nodes through reassociation
> 35: * @library /test/lib /
> 36: * @run driver compiler.c2.loopopts.InvariantCodeMotionReassociateCmp
Suggestion:
* @run main compiler.c2.loopopts.InvariantCodeMotionReassociateCmp
Just like above
-------------
Changes requested by epeter (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17375#pullrequestreview-1951942814
PR Review Comment: https://git.openjdk.org/jdk/pull/17375#discussion_r1533728671
PR Review Comment: https://git.openjdk.org/jdk/pull/17375#discussion_r1533760799
More information about the hotspot-compiler-dev
mailing list