RFR: 8278114: New addnode ideal optimization: converting "x + x" into "x << 1" [v3]
Zhiqiang Zang
duke at openjdk.java.net
Fri Dec 17 18:28:20 UTC 2021
On Thu, 16 Dec 2021 19:10:35 GMT, Claes Redestad <redestad at openjdk.org> 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`.
Thank you both for commenting and suggestions! @merykitty @cl4es
I moved the transformation into LShiftNode, i.e., to convert `(x + x) << 3` into `x << 4`, and I observed a 5% performance improvement (percentage of average time reduced) via the microbenchmark I write. I am not sure how much improvement we usually expect for a transformation, is this one currently a beneficial transformation? Thank you!
-------------
PR: https://git.openjdk.java.net/jdk/pull/6675
More information about the hotspot-compiler-dev
mailing list