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

Joshua Cao duke at openjdk.org
Mon Apr 15 15:57:55 UTC 2024


On Thu, 11 Jan 2024 17:41:53 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.

This pull request has now been integrated.

Changeset: 140f5671
Author:    Joshua Cao <cao.joshua at yahoo.com>
Committer: Emanuel Peter <epeter at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/140f56718bbbfc31bb0c39255c68568fad285a1f
Stats:     997 lines in 4 files changed: 976 ins; 3 del; 18 mod

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

Reviewed-by: epeter, xliu, chagedorn

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

PR: https://git.openjdk.org/jdk/pull/17375


More information about the hotspot-compiler-dev mailing list