Skip to content

Commit b9bdbe9

Browse files
author
Pengfei Li
committed
8305524: AArch64: Fix arraycopy issue on SVE caused by matching rule vmask_gen_sub
Reviewed-by: aph, xgong
1 parent 82e8b03 commit b9bdbe9

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

src/hotspot/cpu/aarch64/aarch64_vector.ad

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5726,7 +5726,7 @@ instruct vmask_gen_I(pReg pd, iRegIorL2I src, rFlagsReg cr) %{
57265726
format %{ "vmask_gen_I $pd, $src\t# KILL cr" %}
57275727
ins_encode %{
57285728
BasicType bt = Matcher::vector_element_basic_type(this);
5729-
__ sve_whilelow($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
5729+
__ sve_whileltw($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
57305730
%}
57315731
ins_pipe(pipe_class_default);
57325732
%}
@@ -5738,7 +5738,7 @@ instruct vmask_gen_L(pReg pd, iRegL src, rFlagsReg cr) %{
57385738
format %{ "vmask_gen_L $pd, $src\t# KILL cr" %}
57395739
ins_encode %{
57405740
BasicType bt = Matcher::vector_element_basic_type(this);
5741-
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
5741+
__ sve_whilelt($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
57425742
%}
57435743
ins_pipe(pipe_slow);
57445744
%}
@@ -5762,7 +5762,7 @@ instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
57625762
format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
57635763
ins_encode %{
57645764
BasicType bt = Matcher::vector_element_basic_type(this);
5765-
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
5765+
__ sve_whilelt($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
57665766
%}
57675767
ins_pipe(pipe_slow);
57685768
%}
@@ -6521,7 +6521,7 @@ instruct mcompress(pReg dst, pReg pg, rFlagsReg cr) %{
65216521
BasicType bt = Matcher::vector_element_basic_type(this);
65226522
Assembler::SIMD_RegVariant size = __ elemType_to_regVariant(bt);
65236523
__ sve_cntp(rscratch1, size, ptrue, $pg$$PRegister);
6524-
__ sve_whilelo(as_PRegister($dst$$reg), size, zr, rscratch1);
6524+
__ sve_whilelt(as_PRegister($dst$$reg), size, zr, rscratch1);
65256525
%}
65266526
ins_pipe(pipe_slow);
65276527
%}

src/hotspot/cpu/aarch64/aarch64_vector_ad.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,7 @@ instruct vmask_gen_I(pReg pd, iRegIorL2I src, rFlagsReg cr) %{
40904090
format %{ "vmask_gen_I $pd, $src\t# KILL cr" %}
40914091
ins_encode %{
40924092
BasicType bt = Matcher::vector_element_basic_type(this);
4093-
__ sve_whilelow($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
4093+
__ sve_whileltw($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
40944094
%}
40954095
ins_pipe(pipe_class_default);
40964096
%}
@@ -4102,7 +4102,7 @@ instruct vmask_gen_L(pReg pd, iRegL src, rFlagsReg cr) %{
41024102
format %{ "vmask_gen_L $pd, $src\t# KILL cr" %}
41034103
ins_encode %{
41044104
BasicType bt = Matcher::vector_element_basic_type(this);
4105-
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
4105+
__ sve_whilelt($pd$$PRegister, __ elemType_to_regVariant(bt), zr, $src$$Register);
41064106
%}
41074107
ins_pipe(pipe_slow);
41084108
%}
@@ -4126,7 +4126,7 @@ instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
41264126
format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
41274127
ins_encode %{
41284128
BasicType bt = Matcher::vector_element_basic_type(this);
4129-
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
4129+
__ sve_whilelt($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
41304130
%}
41314131
ins_pipe(pipe_slow);
41324132
%}
@@ -4852,7 +4852,7 @@ instruct mcompress(pReg dst, pReg pg, rFlagsReg cr) %{
48524852
BasicType bt = Matcher::vector_element_basic_type(this);
48534853
Assembler::SIMD_RegVariant size = __ elemType_to_regVariant(bt);
48544854
__ sve_cntp(rscratch1, size, ptrue, $pg$$PRegister);
4855-
__ sve_whilelo(as_PRegister($dst$$reg), size, zr, rscratch1);
4855+
__ sve_whilelt(as_PRegister($dst$$reg), size, zr, rscratch1);
48564856
%}
48574857
ins_pipe(pipe_slow);
48584858
%}

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,9 +1763,9 @@ void C2_MacroAssembler::sve_gen_mask_imm(PRegister dst, BasicType bt, uint32_t l
17631763
} else if (lane_cnt == max_vector_length - (max_vector_length % 3)) {
17641764
sve_ptrue(dst, size, /* MUL3 */ 0b11110);
17651765
} else {
1766-
// Encode to "whilelow" for the remaining cases.
1766+
// Encode to "whileltw" for the remaining cases.
17671767
mov(rscratch1, lane_cnt);
1768-
sve_whilelow(dst, size, zr, rscratch1);
1768+
sve_whileltw(dst, size, zr, rscratch1);
17691769
}
17701770
}
17711771

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2023, Arm Limited. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8305524
27+
* @run main/othervm -Xbatch compiler.arraycopy.TestArrayCopyMaskedWithSub
28+
*/
29+
30+
package compiler.arraycopy;
31+
32+
public class TestArrayCopyMaskedWithSub {
33+
private static char[] src = {'A', 'A', 'A', 'A', 'A'};
34+
private static char[] dst = {'B', 'B', 'B', 'B', 'B'};
35+
36+
private static void copy(int nlen) {
37+
System.arraycopy(src, 0, dst, 0, -nlen);
38+
}
39+
40+
public static void main(String[] args) {
41+
for (int i = 0; i < 25000; i++) {
42+
copy(0);
43+
}
44+
copy(-5);
45+
for (char c : dst) {
46+
if (c != 'A') {
47+
throw new RuntimeException("Wrong value!");
48+
}
49+
}
50+
System.out.println("PASS");
51+
}
52+
}

0 commit comments

Comments
 (0)