Skip to content

Commit ca4ae80

Browse files
committed
8371964: C2 compilation asserts with "Unexpected load/store size"
Reviewed-by: chagedorn, epeter
1 parent a62296d commit ca4ae80

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/hotspot/share/opto/vectornode.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323

2424
#include "memory/allocation.inline.hpp"
25+
#include "opto/c2_globals.hpp"
26+
#include "opto/compile.hpp"
2527
#include "opto/connode.hpp"
2628
#include "opto/convertnode.hpp"
2729
#include "opto/mulnode.hpp"
@@ -1145,7 +1147,14 @@ Node* LoadVectorMaskedNode::Ideal(PhaseGVN* phase, bool can_reshape) {
11451147
if (ty && ty->is_con()) {
11461148
BasicType mask_bt = Matcher::vector_element_basic_type(in(3));
11471149
int load_sz = type2aelembytes(mask_bt) * ty->get_con();
1148-
assert(load_sz <= MaxVectorSize, "Unexpected load size");
1150+
if (load_sz > MaxVectorSize) {
1151+
// After loop opts, cast nodes are aggressively removed, if the input is then transformed
1152+
// into a constant that is outside the range of the removed cast, we may encounter it here.
1153+
// This should be a dead node then.
1154+
assert(Compile::current()->post_loop_opts_phase(), "Unexpected load size");
1155+
return phase->C->top();
1156+
}
1157+
11491158
if (load_sz == MaxVectorSize) {
11501159
Node* ctr = in(MemNode::Control);
11511160
Node* mem = in(MemNode::Memory);
@@ -1164,7 +1173,14 @@ Node* StoreVectorMaskedNode::Ideal(PhaseGVN* phase, bool can_reshape) {
11641173
if (ty && ty->is_con()) {
11651174
BasicType mask_bt = Matcher::vector_element_basic_type(in(4));
11661175
int load_sz = type2aelembytes(mask_bt) * ty->get_con();
1167-
assert(load_sz <= MaxVectorSize, "Unexpected store size");
1176+
if (load_sz > MaxVectorSize) {
1177+
// After loop opts, cast nodes are aggressively removed, if the input is then transformed
1178+
// into a constant that is outside the range of the removed cast, we may encounter it here.
1179+
// This should be a dead node then.
1180+
assert(Compile::current()->post_loop_opts_phase(), "Unexpected store size");
1181+
return phase->C->top();
1182+
}
1183+
11681184
if (load_sz == MaxVectorSize) {
11691185
Node* ctr = in(MemNode::Control);
11701186
Node* mem = in(MemNode::Memory);

test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, 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
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* @test
29-
* @bug 8251871 8285301
29+
* @bug 8251871 8285301 8371964
3030
* @summary Optimize arrayCopy using AVX-512 masked instructions.
3131
*
3232
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+IgnoreUnrecognizedVMOptions
@@ -52,6 +52,9 @@
5252
* compiler.arraycopy.TestArrayCopyDisjoint
5353
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses
5454
* compiler.arraycopy.TestArrayCopyDisjoint
55+
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+IgnoreUnrecognizedVMOptions
56+
* -XX:+UnlockDiagnosticVMOptions -XX:UseAVX=3 -XX:MaxVectorSize=32 -XX:ArrayOperationPartialInlineSize=32 -XX:+StressIGVN
57+
* compiler.arraycopy.TestArrayCopyDisjoint
5558
*
5659
*/
5760

0 commit comments

Comments
 (0)