Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit 5567530

Browse files
author
Nils Eliasson
committed
8258272: LoadVectorMaskedNode can't be replaced by zero con
Reviewed-by: chagedorn, vlivanov
1 parent a99df45 commit 5567530

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

src/hotspot/share/opto/memnode.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,10 +2044,12 @@ const Type* LoadNode::Value(PhaseGVN* phase) const {
20442044
}
20452045
}
20462046

2047-
if (is_instance) {
2047+
bool is_vect = (_type->isa_vect() != NULL);
2048+
if (is_instance && !is_vect) {
20482049
// If we have an instance type and our memory input is the
20492050
// programs's initial memory state, there is no matching store,
2050-
// so just return a zero of the appropriate type
2051+
// so just return a zero of the appropriate type -
2052+
// except if it is vectorized - then we have no zero constant.
20512053
Node *mem = in(MemNode::Memory);
20522054
if (mem->is_Parm() && mem->in(0)->is_Start()) {
20532055
assert(mem->as_Parm()->_con == TypeFunc::Memory, "must be memory Parm");
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. 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 8258272
27+
* @summary Test that LoadVectorMaskedNodes works when the source array is known to only contain zeros
28+
*
29+
* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,*::testArrayCopy*
30+
* compiler.arraycopy.TestArrayCopyMaskedWithZeroSrc
31+
*/
32+
33+
package compiler.arraycopy;
34+
35+
import java.util.*;
36+
37+
public class TestArrayCopyMaskedWithZeroSrc {
38+
39+
public static void main(String[] args) {
40+
TestArrayCopyMaskedWithZeroSrc t = new TestArrayCopyMaskedWithZeroSrc();
41+
t.test();
42+
}
43+
44+
void test() {
45+
for (int i = 0; i < 20000; i++) {
46+
testArrayCopy1(3);
47+
}
48+
}
49+
50+
// src is allocated locally - it is known it only contains zeros.
51+
// The copy of will exapnd into LoadVectorMasked on AVX512 machines
52+
// LoadNode::value will try to replace the load from src with a zero constant.
53+
54+
byte [] testArrayCopy1(int partial_len) {
55+
byte [] src = new byte[5];
56+
byte [] dest = Arrays.copyOf(src, partial_len);
57+
return dest;
58+
}
59+
}

0 commit comments

Comments
 (0)