RFR: 8276673: Optimize abs operations in C2 compiler [v4]
Jie Fu
jiefu at openjdk.java.net
Fri Dec 17 09:42:26 UTC 2021
On Fri, 17 Dec 2021 09:04:39 GMT, Fei Gao <fgao at openjdk.org> wrote:
> Your cases also help prove that these several patterns, like abs(0-x) and abs(positive_value), are very fundamental and common.
I don't think so.
In real programs, I will never write code like `Math.abs(0 - x)`, `Math.abs(-1 * x)` and `Math.abs(x / (-1))`.
How about improving your micro-bechmark to show the performance gain?
To be honest, benchmarking with `Math.abs(-3)` seems strange to me since I don't think people will write that code.
So I would suggest writing a jmh test which may be used in real programs.
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6755
More information about the hotspot-compiler-dev
mailing list