Integrated: 8321308: AArch64: Fix matching predication for cbz/cbnz
Fei Gao
fgao at openjdk.org
Wed Jun 12 13:32:21 UTC 2024
On Wed, 6 Dec 2023 01:54:59 GMT, Fei Gao <fgao at openjdk.org> wrote:
> For array length check like:
>
> if (a.length > 0) {
> [Block 1]
> } else {
> [Block 2]
> }
>
>
> Since `a.length` is unsigned, it's semantically equivalent to:
>
> if (a.length != 0) {
> [Block 1]
> } else {
> [Block 2]
> }
>
>
> On aarch64 port, we can do the conversion like above, during c2 compiler instruction matching, for certain unsigned integral comparisons.
>
> For example,
>
> cmpw w11, #0 # unsigned
> bls label # unsigned
> [Block 1]
>
> label:
> [Block 2]
>
>
> can be converted to:
>
> cbz w11, label
> [Block 1]
>
> label:
> [Block 2]
>
>
> Currently, we have some matching rules to do the conversion [[1]](https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5bb52f/src/hotspot/cpu/aarch64/aarch64.ad#L15688). But the predicate here [[2]](https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5bb52f/src/hotspot/cpu/aarch64/aarch64.ad#L5631) matches wrong `BoolTest` masks, so these rules fail to convert. I guess it's a typo introduced in [JDK-8160006](https://bugs.openjdk.org/browse/JDK-8160006). The patch fixes it.
This pull request has now been integrated.
Changeset: 2c9185eb
Author: Fei Gao <fgao at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2c9185eb81c9dfcc30d160a6254089c474b56b0d
Stats: 131 lines in 3 files changed: 116 ins; 0 del; 15 mod
8321308: AArch64: Fix matching predication for cbz/cbnz
Reviewed-by: fyang, adinn, aph
-------------
PR: https://git.openjdk.org/jdk/pull/16989
More information about the hotspot-compiler-dev
mailing list