Skip to content

Commit 883e52a

Browse files
Aleksei VoitylovDmitry Chuyko
authored andcommitted
8353237: [AArch64] Incorrect result of VectorizedHashCode intrinsic on Cortex-A53
Reviewed-by: aph
1 parent 13b3541 commit 883e52a

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
@@ -8109,14 +8109,20 @@ class StubGenerator: public StubCodeGenerator {
81098109
__ andr(rscratch2, cnt, vf - 1);
81108110
__ bind(TAIL_SHORTCUT);
81118111
__ adr(rscratch1, BR_BASE);
8112-
__ sub(rscratch1, rscratch1, rscratch2, ext::uxtw, 3);
8112+
// For Cortex-A53 offset is 4 because 2 nops are generated.
8113+
__ sub(rscratch1, rscratch1, rscratch2, ext::uxtw, VM_Version::supports_a53mac() ? 4 : 3);
81138114
__ movw(rscratch2, 0x1f);
81148115
__ br(rscratch1);
81158116

81168117
for (size_t i = 0; i < vf - 1; ++i) {
81178118
__ load(rscratch1, Address(__ post(ary, type2aelembytes(eltype))),
81188119
eltype);
81198120
__ maddw(result, result, rscratch2, rscratch1);
8121+
// maddw generates an extra nop for Cortex-A53 (see maddw definition in macroAssembler).
8122+
// Generate 2nd nop to have 4 instructions per iteration.
8123+
if (VM_Version::supports_a53mac()) {
8124+
__ nop();
8125+
}
81208126
}
81218127
__ bind(BR_BASE);
81228128

0 commit comments

Comments
 (0)