8371964: C2 compilation asserts with "Unexpected load/store size"

Reviewed-by: chagedorn, epeter
This commit is contained in:
Quan Anh Mai 2025-12-02 15:44:19 +00:00
parent a62296d8a0
commit ca4ae8063e
2 changed files with 23 additions and 4 deletions

View File

@ -22,6 +22,8 @@
*/
#include "memory/allocation.inline.hpp"
#include "opto/c2_globals.hpp"
#include "opto/compile.hpp"
#include "opto/connode.hpp"
#include "opto/convertnode.hpp"
#include "opto/mulnode.hpp"
@ -1145,7 +1147,14 @@ Node* LoadVectorMaskedNode::Ideal(PhaseGVN* phase, bool can_reshape) {
if (ty && ty->is_con()) {
BasicType mask_bt = Matcher::vector_element_basic_type(in(3));
int load_sz = type2aelembytes(mask_bt) * ty->get_con();
assert(load_sz <= MaxVectorSize, "Unexpected load size");
if (load_sz > MaxVectorSize) {
// After loop opts, cast nodes are aggressively removed, if the input is then transformed
// into a constant that is outside the range of the removed cast, we may encounter it here.
// This should be a dead node then.
assert(Compile::current()->post_loop_opts_phase(), "Unexpected load size");
return phase->C->top();
}
if (load_sz == MaxVectorSize) {
Node* ctr = in(MemNode::Control);
Node* mem = in(MemNode::Memory);
@ -1164,7 +1173,14 @@ Node* StoreVectorMaskedNode::Ideal(PhaseGVN* phase, bool can_reshape) {
if (ty && ty->is_con()) {
BasicType mask_bt = Matcher::vector_element_basic_type(in(4));
int load_sz = type2aelembytes(mask_bt) * ty->get_con();
assert(load_sz <= MaxVectorSize, "Unexpected store size");
if (load_sz > MaxVectorSize) {
// After loop opts, cast nodes are aggressively removed, if the input is then transformed
// into a constant that is outside the range of the removed cast, we may encounter it here.
// This should be a dead node then.
assert(Compile::current()->post_loop_opts_phase(), "Unexpected store size");
return phase->C->top();
}
if (load_sz == MaxVectorSize) {
Node* ctr = in(MemNode::Control);
Node* mem = in(MemNode::Memory);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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
@ -26,7 +26,7 @@ import java.util.Random;
/**
* @test
* @bug 8251871 8285301
* @bug 8251871 8285301 8371964
* @summary Optimize arrayCopy using AVX-512 masked instructions.
*
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+IgnoreUnrecognizedVMOptions
@ -52,6 +52,9 @@ import java.util.Random;
* compiler.arraycopy.TestArrayCopyDisjoint
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses
* compiler.arraycopy.TestArrayCopyDisjoint
* @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch -XX:+IgnoreUnrecognizedVMOptions
* -XX:+UnlockDiagnosticVMOptions -XX:UseAVX=3 -XX:MaxVectorSize=32 -XX:ArrayOperationPartialInlineSize=32 -XX:+StressIGVN
* compiler.arraycopy.TestArrayCopyDisjoint
*
*/