RFR: 8276673: Optimize abs operations in C2 compiler [v6]

Fei Gao fgao at openjdk.java.net
Mon Dec 20 09:43:25 UTC 2021


On Mon, 20 Dec 2021 06:13:34 GMT, Jie Fu <jiefu at openjdk.org> wrote:

> But can you show us an example with more detailed analysis which pattern is applied in the test? Thanks.

Hi, @DamonFool 

For example, `jdk/incubator/vector/Float512VectorTests.java` calls `java.lang.FdLibm$Hypot::compute`. You can check math classes in `Fdlibm.java`, like `Hypot`  or a common one `Pow`, which call `Math.abs()`. After inline and many optimizations, such as constant propagation, the input value of `Math.abs()` is probably constant or `(0-x)`. We can optimize it using this patch.

I learnt the optimization technique from the patch of my colleague, https://github.com/openjdk/jdk/pull/2776#issuecomment-789756226
The similar question was answered by Tobias in the conversation, and you can refer to it.

Thanks.

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

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


More information about the hotspot-compiler-dev mailing list