RFR: 8278114: New addnode ideal optimization: converting "x + x" into "x << 1" [v3]

Claes Redestad redestad at openjdk.java.net
Thu Dec 16 19:14:00 UTC 2021


On Thu, 16 Dec 2021 18:36:31 GMT, Mai Đặng Quân Anh <duke at openjdk.java.net> wrote:

> Tbh I don't find this transformation necessary, `x + x` is a very cheap operation and is generally easier for the optimiser to work with than `x << 1`. Cheers.

I agree this looks to be of dubious value on the face of it. A microbenchmark to prove it's beneficial in some scenario feels like a requirement here.

A targeted microbenchmark could explore if we already do or could better allow constant folding of expressions that does subsequent shifts, e.g. by turning `(x + x) << 3` into `x << 4`.

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

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


More information about the hotspot-compiler-dev mailing list