Skip to content

Commit b6ec93b

Browse files
8359121: C2: Region added by vectorizedMismatch intrinsic can survive as a dead node after IGVN
Reviewed-by: thartmann, chagedorn
1 parent 65e63b6 commit b6ec93b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/hotspot/share/opto/library_call.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6580,6 +6580,10 @@ bool LibraryCallKit::inline_vectorizedMismatch() {
65806580
memory_phi = _gvn.transform(memory_phi);
65816581
result_phi = _gvn.transform(result_phi);
65826582

6583+
record_for_igvn(exit_block);
6584+
record_for_igvn(memory_phi);
6585+
record_for_igvn(result_phi);
6586+
65836587
set_control(exit_block);
65846588
set_all_memory(memory_phi);
65856589
set_result(result_phi);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2025, 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 8359121
27+
* @summary Region node introduced by ArraysSupport.mismatch must be disconnected,
28+
* and not just put aside as dead: when simplifying
29+
* Proj -> Region -> If -> ...
30+
* into
31+
* Proj -> If -> ...
32+
* -> Region
33+
* the dead Region node must be removed from Proj's outputs.
34+
* @modules java.base/jdk.internal.util
35+
* @run main/othervm -Xcomp
36+
* -XX:CompileCommand=compileonly,compiler.igvn.RemoveDeadRegionFromVectorizedMismatchIntrinsic::test
37+
* compiler.igvn.RemoveDeadRegionFromVectorizedMismatchIntrinsic
38+
* @run main compiler.igvn.RemoveDeadRegionFromVectorizedMismatchIntrinsic
39+
*/
40+
package compiler.igvn;
41+
42+
import jdk.internal.util.ArraysSupport;
43+
44+
public class RemoveDeadRegionFromVectorizedMismatchIntrinsic {
45+
public static void main(String[] args) {
46+
ArraysSupport.mismatch(new int[0], new int[0], 0); // loads ArraysSupport
47+
test(new byte[0], new byte[0]);
48+
}
49+
50+
public static int test(byte[] a, byte[] b) {
51+
int i = ArraysSupport.vectorizedMismatch(a, 0, b, 0, 0, 0);
52+
return i >= 0 ? i : 0;
53+
}
54+
}

0 commit comments

Comments
 (0)