diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index a49f3d24fd4ac..57b94205e5e7d 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -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); diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java index 162ba20048da5..73b1af9054831 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyDisjoint.java @@ -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 @@ /** * @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 @@ * 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 * */