Integrated: 8283094: Add Ideal transformation: x + (con - y) -> (x - y) + con

Zhiqiang Zang duke at openjdk.java.net
Wed Apr 13 16:05:20 UTC 2022


On Fri, 11 Mar 2022 23:40:19 GMT, Zhiqiang Zang <duke at openjdk.java.net> wrote:

> Hello,
> 
> `x + (con - y)  -> (x - y) + con` is a widely seen pattern; however it is missing in current implementation, which prevents some obvious constant folding from happening, such as `x + (1 - y) + 2` will be not optimized at all, rather than into `x - y + 3`.
> 
> This pull request adds this transformation.

This pull request has now been integrated.

Changeset: c7755b81
Author:    Zhiqiang Zang <zhiqiang.zang at utexas.edu>
Committer: Vladimir Kozlov <kvn at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/c7755b815d149425534aa4344c753591aa41b725
Stats:     135 lines in 5 files changed: 107 ins; 0 del; 28 mod

8283094: Add Ideal transformation: x + (con - y) -> (x - y) + con

Reviewed-by: kvn, thartmann

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

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


More information about the hotspot-compiler-dev mailing list