Skip to content

Commit 81b0d41

Browse files
committed
8353237: [AArch64] Incorrect result of VectorizedHashCode intrinsic on Cortex-A53
Backport-of: 883e52a
1 parent 2867616 commit 81b0d41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,20 @@ address C2_MacroAssembler::arrays_hashcode(Register ary, Register cnt, Register
107107
assert(is_power_of_2(unroll_factor), "can't use this value to calculate the jump target PC");
108108
andr(tmp2, cnt, unroll_factor - 1);
109109
adr(tmp1, BR_BASE);
110-
sub(tmp1, tmp1, tmp2, ext::sxtw, 3);
110+
// For Cortex-A53 offset is 4 because 2 nops are generated.
111+
sub(tmp1, tmp1, tmp2, ext::sxtw, VM_Version::supports_a53mac() ? 4 : 3);
111112
movw(tmp2, 0x1f);
112113
br(tmp1);
113114

114115
bind(LOOP);
115116
for (size_t i = 0; i < unroll_factor; ++i) {
116117
load(tmp1, Address(post(ary, type2aelembytes(eltype))), eltype);
117118
maddw(result, result, tmp2, tmp1);
119+
// maddw generates an extra nop for Cortex-A53 (see maddw definition in macroAssembler).
120+
// Generate 2nd nop to have 4 instructions per iteration.
121+
if (VM_Version::supports_a53mac()) {
122+
nop();
123+
}
118124
}
119125
bind(BR_BASE);
120126
subsw(cnt, cnt, unroll_factor);

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5472,14 +5472,20 @@ class StubGenerator: public StubCodeGenerator {
54725472
__ andr(rscratch2, cnt, vf - 1);
54735473
__ bind(TAIL_SHORTCUT);
54745474
__ adr(rscratch1, BR_BASE);
5475-
__ sub(rscratch1, rscratch1, rscratch2, ext::uxtw, 3);
5475+
// For Cortex-A53 offset is 4 because 2 nops are generated.
5476+
__ sub(rscratch1, rscratch1, rscratch2, ext::uxtw, VM_Version::supports_a53mac() ? 4 : 3);
54765477
__ movw(rscratch2, 0x1f);
54775478
__ br(rscratch1);
54785479

54795480
for (size_t i = 0; i < vf - 1; ++i) {
54805481
__ load(rscratch1, Address(__ post(ary, type2aelembytes(eltype))),
54815482
eltype);
54825483
__ maddw(result, result, rscratch2, rscratch1);
5484+
// maddw generates an extra nop for Cortex-A53 (see maddw definition in macroAssembler).
5485+
// Generate 2nd nop to have 4 instructions per iteration.
5486+
if (VM_Version::supports_a53mac()) {
5487+
__ nop();
5488+
}
54835489
}
54845490
__ bind(BR_BASE);
54855491

0 commit comments

Comments
 (0)