RFR: 8283094: Add Ideal transformation: x + (con - y) -> (x - y) + con [v5]

Zhiqiang Zang duke at openjdk.java.net
Tue Mar 29 21:09:46 UTC 2022


On Tue, 29 Mar 2022 20:56:02 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Thanks for reviewing! That is indeed an interesting observation. I feel `con - y` could not be a loop increment so it should be sufficient to check `x` is not a loop induction variable?
>
> I think we need to check `y`. For example:
> 
> 
> for (int i = 0; i < 10000; i++) {
>     a[MAX - i] = b[MAX - i];
> }

But in this case it seems OK to me to make the transformation, for example:

for (int i = 0; i < 10000; i++) {
    a[x + (MAX - i)] = b[x + (MAX - i)]; // a[(x - i) + MAX] = b[(x - i) + MAX]
}

Is there something I overlooked?

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

PR: https://git.openjdk.java.net/jdk/pull/7795


More information about the hotspot-compiler-dev mailing list