From 6ca9542770491583a72e2334e6ef15ed8ca76392 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Thu, 27 Nov 2025 13:10:38 +0000 Subject: [PATCH 1/5] 8337791: VectorAPI jtreg ABSMaskedByteMaxVectorTests crash with UseAVX=0 -XX:MaxVectorSize=8 --- src/hotspot/cpu/x86/x86.ad | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index be9889b0a9990..dd134b0567e02 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -3320,6 +3320,11 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; + case Op_VectorBlend: + if (UseAVX == 0 && MaxVectorSize < 16) { + return false; + } + break; case Op_VectorTest: if (UseSSE < 4) { return false; // Implementation limitation From 2c08c7db9359b10af98ec38d0753cebd1eaa8718 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Thu, 27 Nov 2025 20:55:43 +0530 Subject: [PATCH 2/5] Fine tune matcher check --- src/hotspot/cpu/x86/x86.ad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index dd134b0567e02..bd67cd5d8d8e9 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -3321,7 +3321,7 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { } break; case Op_VectorBlend: - if (UseAVX == 0 && MaxVectorSize < 16) { + if (UseAVX == 0 && size_in_bits < 128) { return false; } break; From be24b1afcfaf2011f30675e8dc53fc09baa70072 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 1 Dec 2025 07:09:54 +0000 Subject: [PATCH 3/5] Adding a testpoint --- .../vectorapi/TestABSMaskedMaxByteVector.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java new file mode 100644 index 0000000000000..0dddfc4b1398e --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.vectorapi; + +import compiler.lib.ir_framework.*; +import jdk.incubator.vector.*; + +/* + * @test + * @bug 8337791 + * @summary Test byte vector predicated ABS with UseAVX=0 and MaxVectorSize=8 + * @modules jdk.incubator.vector + * @library /test/lib / + * @run driver compiler.vectorapi.TestABSMaskedMaxByteVector + */ + +public class TestABSMaskedMaxByteVector { + public static final VectorSpecies BSP = ByteVector.SPECIES_MAX; + public static int idx = 0; + + public static void main(String[] args) { + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-ea", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:UseAVX=0", "-XX:MaxVectorSize=8"); + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-ea"); + } + + @Test + @IR(failOn = {IRNode.ABS_VB}, applyIfAnd={"MaxVectorSize", " <= 8 ", "UseAVX", "0"}) + @IR(counts = {IRNode.ABS_VB, "1"}, applyIf={"MaxVectorSize", " > 8 "}) + public void test() { + assert ByteVector.broadcast(BSP, (byte)-4) + .lanewise(VectorOperators.ABS, VectorMask.fromLong(BSP, 0xF)) + .lane(idx++ & 1) >= 4; + } +} From ef84ffa799a08358b1d1715a141d49ee1d12fc85 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 1 Dec 2025 13:34:21 +0000 Subject: [PATCH 4/5] Review comments resolutions --- .../compiler/vectorapi/TestABSMaskedMaxByteVector.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java index 0dddfc4b1398e..870c39523f33e 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java @@ -44,11 +44,11 @@ public static void main(String[] args) { } @Test - @IR(failOn = {IRNode.ABS_VB}, applyIfAnd={"MaxVectorSize", " <= 8 ", "UseAVX", "0"}) - @IR(counts = {IRNode.ABS_VB, "1"}, applyIf={"MaxVectorSize", " > 8 "}) + @IR(failOn = {IRNode.ABS_VB}, applyIfAnd={"MaxVectorSize", " <= 8 ", "UseAVX", "0"}, applyIfPlatform={"x64", "true"}, applyIfCPUFeature={"sse4.1", "true"}) + @IR(counts = {IRNode.ABS_VB, "1"}, applyIf={"MaxVectorSize", " > 8 "}, applyIfPlatform={"x64", "true"}, applyIfCPUFeature={"sse4.1", "true"}) public void test() { assert ByteVector.broadcast(BSP, (byte)-4) .lanewise(VectorOperators.ABS, VectorMask.fromLong(BSP, 0xF)) - .lane(idx++ & 1) >= 4; + .lane(idx++ & 3) == 4; } } From e92cd4670ae677f07a5ade3195b276822cf18210 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Wed, 3 Dec 2025 23:55:32 +0530 Subject: [PATCH 5/5] Update test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Lundén --- .../jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java index 870c39523f33e..356892fadf88e 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestABSMaskedMaxByteVector.java @@ -44,8 +44,8 @@ public static void main(String[] args) { } @Test - @IR(failOn = {IRNode.ABS_VB}, applyIfAnd={"MaxVectorSize", " <= 8 ", "UseAVX", "0"}, applyIfPlatform={"x64", "true"}, applyIfCPUFeature={"sse4.1", "true"}) - @IR(counts = {IRNode.ABS_VB, "1"}, applyIf={"MaxVectorSize", " > 8 "}, applyIfPlatform={"x64", "true"}, applyIfCPUFeature={"sse4.1", "true"}) + @IR(failOn = {IRNode.ABS_VB}, applyIfAnd = {"MaxVectorSize", " <= 8 ", "UseAVX", "0"}, applyIfPlatform = {"x64", "true"}, applyIfCPUFeature = {"sse4.1", "true"}) + @IR(counts = {IRNode.ABS_VB, "1"}, applyIf = {"MaxVectorSize", " > 8 "}, applyIfPlatform = {"x64", "true"}, applyIfCPUFeature = {"sse4.1", "true"}) public void test() { assert ByteVector.broadcast(BSP, (byte)-4) .lanewise(VectorOperators.ABS, VectorMask.fromLong(BSP, 0xF))