From 38b66b12581a3745a37589e32aa0fc880d27b4d4 Mon Sep 17 00:00:00 2001 From: Xiaohong Gong Date: Mon, 26 Jan 2026 01:50:57 +0000 Subject: [PATCH] 8374043: C2: assert(_base >= VectorMask && _base <= VectorZ) failed: Not a Vector Reviewed-by: qamai, vlivanov --- src/hotspot/share/opto/vectorIntrinsics.cpp | 4 ++++ src/hotspot/share/opto/vectornode.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 65d54e076b6..883a0526053 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -175,6 +175,10 @@ Node* GraphKit::unbox_vector(Node* v, const TypeInstPtr* vbox_type, BasicType el assert(check_vbox(vbox_type), ""); const TypeVect* vt = TypeVect::make(elem_bt, num_elem, is_vector_mask(vbox_type->instance_klass())); Node* unbox = gvn().transform(new VectorUnboxNode(C, vt, v, merged_memory())); + if (gvn().type(unbox)->isa_vect() == nullptr) { + assert(gvn().type(unbox) == Type::TOP, "sanity"); + return nullptr; // not a vector + } return unbox; } diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index 271dc901dcb..7401efaf7c2 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, 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 @@ -1919,6 +1919,15 @@ Node* VectorMaskToLongNode::Ideal_MaskAll(PhaseGVN* phase) { // saved with a predicate type. if (in1->Opcode() == Op_VectorStoreMask) { Node* mask = in1->in(1); + // Skip the optimization if the mask is dead. + if (phase->type(mask) == Type::TOP) { + return nullptr; + } + // If the ideal graph is transformed correctly, the input mask should be a + // vector type node. Following optimization can ignore the mismatched type + // issue. But we still keep the sanity check for the mask type by using + // "is_vect()" in the assertion below, so that there can be less optimizations + // evolved before the compiler finally runs into a problem. assert(!Matcher::mask_op_prefers_predicate(Opcode(), mask->bottom_type()->is_vect()), "sanity"); in1 = mask; }