8367483: C2 crash in PhaseValues::type: assert(t != nullptr) failed: must set before get - missing notification for CastX2P(SubL(x, y))

Reviewed-by: chagedorn, bmaillard
This commit is contained in:
Emanuel Peter 2025-09-12 12:06:18 +00:00
parent 15dd96f7a6
commit 02d7281b93
2 changed files with 63 additions and 1 deletions

View File

@ -2645,7 +2645,11 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
worklist.push(cmp);
}
}
if (use->Opcode() == Op_AddX) {
// From CastX2PNode::Ideal
// CastX2P(AddX(x, y))
// CastX2P(SubX(x, y))
if (use->Opcode() == Op_AddX || use->Opcode() == Op_SubX) {
for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
Node* u = use->fast_out(i2);
if (u->Opcode() == Op_CastX2P) {

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8367483
* @summary Missed worklist notification during IGVN for CastX2P(SubX(x, y)) pattern,
* leads to missed optimization.
* @run main/othervm
* -XX:CompileCommand=compileonly,compiler.igvn.MissedOptimizationWithCastX2PSubX::test
* -XX:-TieredCompilation
* -XX:+IgnoreUnrecognizedVMOptions
* -XX:VerifyIterativeGVN=1110
* compiler.igvn.MissedOptimizationWithCastX2PSubX
* @run main compiler.igvn.MissedOptimizationWithCastX2PSubX
*/
package compiler.igvn;
import java.lang.foreign.*;
public class MissedOptimizationWithCastX2PSubX {
public static void main(String[] args) {
MemorySegment a = Arena.ofAuto().allocate(74660);
MemorySegment b = Arena.ofAuto().allocate(74660);
for (int i = 0; i < 1_000; i++) {
test(a, 69830/2 - 100, b, -10_000, 0, 1_000);
}
}
public static void test(MemorySegment a, long invarA, MemorySegment b, long invarB, long ivLo, long ivHi) {
for (long i = ivHi-1; i >= ivLo; i-=1) {
a.set(ValueLayout.JAVA_CHAR_UNALIGNED, 69830L + 2L * i + -2L * invarA, (char)42);
b.set(ValueLayout.JAVA_FLOAT_UNALIGNED, 9071L + -4L * i + -4L * invarB, 42);
}
}
}