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);
0 commit comments