RFR: 8277850: C2: optimize mask checks in counted loops
Vladimir Kozlov
kvn at openjdk.java.net
Mon Dec 6 17:46:14 UTC 2021
On Fri, 3 Dec 2021 10:04:58 GMT, Roland Westrelin <roland at openjdk.org> wrote:
> This is another fix that addresses a performance issue with panama and that was brought up by Maurizio. The pattern to optimize is:
> if ((base + (offset << 2)) & 3) != 0) {
> }
>
> where base is loop independent but offset depends on a loop variable. This can be transformed to:
>
> if ((base & 3) != 0) {
>
> That check becomes loop independent and be optimized by loop predication (or I suppose loop unswitching but that wasn't the case of the micro benchmark I worked on).
>
> This change also optimizes the pattern:
>
> (offset << 2) & 3
>
> to return 0.
src/hotspot/share/opto/mulnode.hpp line 86:
> 84: static MulNode* make(Node* in1, Node* in2, BasicType bt);
> 85:
> 86: bool AndIL_shift_and_mask(PhaseGVN* phase, Node* mask, Node* shift, BasicType bt) const;
This one could be static method.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6697
More information about the hotspot-compiler-dev
mailing list