RFR: 8267687: ModXNode::Ideal optimization is better than Parse::do_irem
Yi Yang
yyang at openjdk.java.net
Wed May 26 01:28:33 UTC 2021
Hi all,
Can I have a review of this change? I noticed there are two almost the same optimizations for % operation. For x%y, both Parse::do_irem and ModXNode::ideal are optimized for a special case that divisor y is `2^n` constant value.
ModXNode::Ideal opt:
https://github.com/openjdk/jdk/blob/cc687fd43ade6be8760c559f3ffa909c5937727c/src/hotspot/share/opto/divnode.cpp#L112-L160
Parse::do_irem opt:
https://github.com/openjdk/jdk/blob/cc687fd43ade6be8760c559f3ffa909c5937727c/src/hotspot/share/opto/parse2.cpp#L1171-L1196
It turns out that ModXNode::Ideal optimization is better than Parse::do_irem in a simple microbenchmark(Please check out JBS attachment for detailed benchmark result):
ModXNode::Ideal opt:
----------------
Benchmark Mode Cnt Score Error Units
ModPowerOf2.testNegativePowerOf2 avgt 25 8746.608 ± 139.777 ns/op
ModPowerOf2.testPositivePowerOf2 avgt 25 8735.545 ± 86.145 ns/op
Parse::do_irem opt:
----------------
Benchmark Mode Cnt Score Error Units
ModPowerOf2.testNegativePowerOf2 avgt 25 8693.797 ± 7.844 ns/op
ModPowerOf2.testPositivePowerOf2 avgt 25 6618.652 ± 1.739 ns/op
Diff for ideal graph:
----------------

Thanks!
Yang
-------------
Commit messages:
- tailing whitespace
- use ModXNode::Ideal; remove Parse::do_irem opt
Changes: https://git.openjdk.java.net/jdk/pull/4188/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4188&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8267687
Stats: 160 lines in 3 files changed: 101 ins; 58 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/4188.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4188/head:pull/4188
PR: https://git.openjdk.java.net/jdk/pull/4188
More information about the hotspot-compiler-dev
mailing list