Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit ac4f14c

Browse files
author
Pengfei Li
committedJun 28, 2020
8247307: C2: Loop array fill stub routines are not called
Ignore safepoint polling use of CountedLoopNode when matching loop array fill pattern. Reviewed-by: kvn, thartmann
1 parent bdab5a0 commit ac4f14c

File tree

3 files changed

+120
-5
lines changed

3 files changed

+120
-5
lines changed
 

‎src/hotspot/cpu/x86/vm_version_x86.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,12 @@ void VM_Version::get_processor_features() {
15071507
// Modern processors allow misaligned memory operations for vectors.
15081508
AlignVector = !UseUnalignedLoadStores;
15091509
}
1510+
if (FLAG_IS_DEFAULT(OptimizeFill)) {
1511+
// 8247307: On x86, the auto-vectorized loop array fill code shows
1512+
// better performance than the array fill stubs. We should reenable
1513+
// this after the x86 stubs get improved.
1514+
OptimizeFill = false;
1515+
}
15101516
#endif // COMPILER2
15111517

15121518
if (FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {

‎src/hotspot/share/opto/loopTransform.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -3642,10 +3642,21 @@ bool PhaseIdealLoop::match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& st
36423642
for (SimpleDUIterator iter(n); iter.has_next(); iter.next()) {
36433643
Node* use = iter.get();
36443644
if (!lpt->_body.contains(use)) {
3645-
msg = "node is used outside loop";
3646-
// lpt->_body.dump();
3647-
msg_node = n;
3648-
break;
3645+
if (n->is_CountedLoop() && n->as_CountedLoop()->is_strip_mined()) {
3646+
// In strip-mined counted loops, the CountedLoopNode may be
3647+
// used by the address polling node of the outer safepoint.
3648+
// Skip this use because it's safe.
3649+
#ifdef ASSERT
3650+
Node* sfpt = n->as_CountedLoop()->outer_safepoint();
3651+
Node* polladr = sfpt->in(TypeFunc::Parms+0);
3652+
assert(use == polladr, "the use should be a safepoint polling");
3653+
#endif
3654+
continue;
3655+
} else {
3656+
msg = "node is used outside loop";
3657+
msg_node = n;
3658+
break;
3659+
}
36493660
}
36503661
}
36513662
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2020, Arm Limited. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*/
24+
25+
package org.openjdk.bench.vm.compiler;
26+
27+
import org.openjdk.jmh.annotations.Benchmark;
28+
import org.openjdk.jmh.annotations.BenchmarkMode;
29+
import org.openjdk.jmh.annotations.Mode;
30+
import org.openjdk.jmh.annotations.OutputTimeUnit;
31+
import org.openjdk.jmh.annotations.Param;
32+
import org.openjdk.jmh.annotations.Scope;
33+
import org.openjdk.jmh.annotations.Setup;
34+
import org.openjdk.jmh.annotations.State;
35+
36+
import java.util.concurrent.TimeUnit;
37+
import java.util.Arrays;
38+
39+
@State(Scope.Benchmark)
40+
@BenchmarkMode(Mode.AverageTime)
41+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
42+
public class ArrayFill {
43+
@Param("65536") private int size;
44+
45+
private byte[] ba;
46+
private short[] sa;
47+
private int[] ia;
48+
49+
@Setup
50+
public void setup() {
51+
ba = new byte[size];
52+
sa = new short[size];
53+
ia = new int[size];
54+
}
55+
56+
@Benchmark
57+
public void fillByteArray() {
58+
for (int i = 0; i < size; i++) {
59+
ba[i] = (byte) 123;
60+
}
61+
}
62+
63+
@Benchmark
64+
public void fillShortArray() {
65+
for (int i = 0; i < size; i++) {
66+
sa[i] = (short) 12345;
67+
}
68+
}
69+
70+
@Benchmark
71+
public void fillIntArray() {
72+
for (int i = 0; i < size; i++) {
73+
ia[i] = 1234567890;
74+
}
75+
}
76+
77+
@Benchmark
78+
public void zeroByteArray() {
79+
for (int i = 0; i < size; i++) {
80+
ba[i] = 0;
81+
}
82+
}
83+
84+
@Benchmark
85+
public void zeroShortArray() {
86+
for (int i = 0; i < size; i++) {
87+
sa[i] = 0;
88+
}
89+
}
90+
91+
@Benchmark
92+
public void zeroIntArray() {
93+
for (int i = 0; i < size; i++) {
94+
ia[i] = 0;
95+
}
96+
}
97+
}
98+

0 commit comments

Comments
 (0)
This repository has been archived.