Skip to content

Commit

Permalink
Redefine the interface for cmpOpUEqNeLeGt
Browse files Browse the repository at this point in the history
  • Loading branch information
fg1417 committed Jun 6, 2024
1 parent 6883ba9 commit c49553b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
20 changes: 12 additions & 8 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -5642,10 +5642,10 @@ operand cmpOpUEqNeLeGt()
interface(COND_INTER) %{
equal(0x0, "eq");
not_equal(0x1, "ne");
less(0xb, "lt");
greater_equal(0xa, "ge");
less_equal(0xd, "le");
greater(0xc, "gt");
less(0x3, "lo");
greater_equal(0x2, "hs");
less_equal(0x9, "ls");
greater(0x8, "hi");
overflow(0x6, "vs");
no_overflow(0x7, "vc");
%}
Expand Down Expand Up @@ -15694,10 +15694,12 @@ instruct cmpUI_imm0_branch(cmpOpUEqNeLeGt cmp, iRegIorL2I op1, immI0 op2, label
ins_encode %{
Label* L = $labl$$label;
Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
if (cond == Assembler::EQ || cond == Assembler::LE)
if (cond == Assembler::EQ || cond == Assembler::LS) {
__ cbzw($op1$$Register, *L);
else
} else {
assert(cond == Assembler::NE || cond == Assembler::HI, "unexpected condition");
__ cbnzw($op1$$Register, *L);
}
%}
ins_pipe(pipe_cmp_branch);
%}
Expand All @@ -15711,10 +15713,12 @@ instruct cmpUL_imm0_branch(cmpOpUEqNeLeGt cmp, iRegL op1, immL0 op2, label labl)
ins_encode %{
Label* L = $labl$$label;
Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
if (cond == Assembler::EQ || cond == Assembler::LE)
if (cond == Assembler::EQ || cond == Assembler::LS) {
__ cbz($op1$$Register, *L);
else
} else {
assert(cond == Assembler::NE || cond == Assembler::HI, "unexpected condition");
__ cbnz($op1$$Register, *L);
}
%}
ins_pipe(pipe_cmp_branch);
%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Arm Limited. All rights reserved.
* Copyright (c) 2024, Arm Limited. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,13 +40,13 @@ public class TestArrLenCheckOptimization {
int result = 0;

@Test
@IR(counts = {IRNode.CBZW_LE, "1"})
@IR(counts = {IRNode.CBZW_LS, "1"})
void test_le_int(int ia[]) {
result += ia[0];
}

@Test
@IR(counts = {IRNode.CBNZW_GT, "1"})
@IR(counts = {IRNode.CBNZW_HI, "1"})
void test_gt_int(int ia[]) {
if (ia.length > 0) {
result += 0x88;
Expand All @@ -56,20 +56,33 @@ void test_gt_int(int ia[]) {
}

@Test
@IR(counts = {IRNode.CBZ_LE, "1"})
@IR(counts = {IRNode.CBZ_LS, "1"})
void test_le_long(int ia[]) {
int limit = ia.length-1;
for (int i = 0; i < ia.length; i += 1) {
ia[limit-i] = -123;
if (Long.compareUnsigned(ia.length, 0) > 0) {
result += 0x80;
} else {
result -= 1;
}
}

@Test
@IR(counts = {IRNode.CBZ_HI, "1"})
void test_gt_long(int ia[]) {
if (Long.compareUnsigned(ia.length, 0) > 0) {
result += 0x82;
} else {
result -= 1;
}
}

@Run(test = {"test_le_int", "test_gt_int", "test_le_long"}, mode = RunMode.STANDALONE)
@Run(test = {"test_le_int", "test_gt_int", "test_le_long", "test_gt_long"},
mode = RunMode.STANDALONE)
public void test_runner() {
for (int i = 0; i < 10_000; i++) {
test_le_int(new int[1]);
test_gt_int(new int[0]);
test_le_long(new int[i]);
test_le_long(new int[1]);
test_gt_long(new int[0]);
}
}

Expand Down
17 changes: 11 additions & 6 deletions test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,24 @@ public class IRNode {
beforeMatchingNameRegex(CAST_LL, "CastLL");
}

public static final String CBNZW_GT = PREFIX + "CBNZW_GT" + POSTFIX;
public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
static {
optoOnly(CBNZW_GT, "cbwgt");
optoOnly(CBNZW_HI, "cbwhi");
}

public static final String CBZW_LE = PREFIX + "CBZW_LE" + POSTFIX;
public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
static {
optoOnly(CBZW_LE, "cbwle");
optoOnly(CBZW_LS, "cbwls");
}

public static final String CBZ_LE = PREFIX + "CBZ_LE" + POSTFIX;
public static final String CBZ_LS = PREFIX + "CBZ_LS" + POSTFIX;
static {
optoOnly(CBZ_LE, "cble");
optoOnly(CBZ_LS, "cbls");
}

public static final String CBZ_HI = PREFIX + "CBZ_HI" + POSTFIX;
static {
optoOnly(CBZ_HI, "cbhi");
}

public static final String CHECKCAST_ARRAY = PREFIX + "CHECKCAST_ARRAY" + POSTFIX;
Expand Down

0 comments on commit c49553b

Please sign in to comment.