Skip to content

Commit 2805c05

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents b421d3a + 02d7281 commit 2805c05

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/hotspot/share/opto/phaseX.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,11 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
26452645
worklist.push(cmp);
26462646
}
26472647
}
2648-
if (use->Opcode() == Op_AddX) {
2648+
2649+
// From CastX2PNode::Ideal
2650+
// CastX2P(AddX(x, y))
2651+
// CastX2P(SubX(x, y))
2652+
if (use->Opcode() == Op_AddX || use->Opcode() == Op_SubX) {
26492653
for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
26502654
Node* u = use->fast_out(i2);
26512655
if (u->Opcode() == Op_CastX2P) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 8367483
27+
* @summary Missed worklist notification during IGVN for CastX2P(SubX(x, y)) pattern,
28+
* leads to missed optimization.
29+
* @run main/othervm
30+
* -XX:CompileCommand=compileonly,compiler.igvn.MissedOptimizationWithCastX2PSubX::test
31+
* -XX:-TieredCompilation
32+
* -XX:+IgnoreUnrecognizedVMOptions
33+
* -XX:VerifyIterativeGVN=1110
34+
* compiler.igvn.MissedOptimizationWithCastX2PSubX
35+
* @run main compiler.igvn.MissedOptimizationWithCastX2PSubX
36+
*/
37+
38+
package compiler.igvn;
39+
40+
import java.lang.foreign.*;
41+
42+
public class MissedOptimizationWithCastX2PSubX {
43+
public static void main(String[] args) {
44+
MemorySegment a = Arena.ofAuto().allocate(74660);
45+
MemorySegment b = Arena.ofAuto().allocate(74660);
46+
47+
for (int i = 0; i < 1_000; i++) {
48+
test(a, 69830/2 - 100, b, -10_000, 0, 1_000);
49+
}
50+
}
51+
52+
public static void test(MemorySegment a, long invarA, MemorySegment b, long invarB, long ivLo, long ivHi) {
53+
for (long i = ivHi-1; i >= ivLo; i-=1) {
54+
a.set(ValueLayout.JAVA_CHAR_UNALIGNED, 69830L + 2L * i + -2L * invarA, (char)42);
55+
b.set(ValueLayout.JAVA_FLOAT_UNALIGNED, 9071L + -4L * i + -4L * invarB, 42);
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)