diff --git a/src/hotspot/cpu/aarch64/aarch64_vector.ad b/src/hotspot/cpu/aarch64/aarch64_vector.ad index 31427871120..d49c0eb416f 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector.ad +++ b/src/hotspot/cpu/aarch64/aarch64_vector.ad @@ -5689,6 +5689,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{ ins_pipe(pipe_slow); %} +instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{ + predicate(UseSVE > 0); + match(Set pd (VectorMaskGen (SubL src1 src2))); + effect(KILL cr); + format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %} + ins_encode %{ + BasicType bt = Matcher::vector_element_basic_type(this); + __ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register); + %} + ins_pipe(pipe_slow); +%} + // ------------------------------ Popcount vector ------------------------------ // vector popcount - INT diff --git a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 index 9c458399e44..6cb7e23b249 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 +++ b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 @@ -4072,6 +4072,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{ ins_pipe(pipe_slow); %} +instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{ + predicate(UseSVE > 0); + match(Set pd (VectorMaskGen (SubL src1 src2))); + effect(KILL cr); + format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %} + ins_encode %{ + BasicType bt = Matcher::vector_element_basic_type(this); + __ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register); + %} + ins_pipe(pipe_slow); +%} + // ------------------------------ Popcount vector ------------------------------ // vector popcount - INT diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 92ab554d620..02be97362c7 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -1211,6 +1211,16 @@ class methodHandle; "Ljdk/internal/vm/vector/VectorSupport$Vector;") \ do_name(index_vector_op_name, "indexVector") \ \ + do_intrinsic(_IndexPartiallyInUpperRange, jdk_internal_vm_vector_VectorSupport, index_partially_in_upper_range_name, index_partially_in_upper_range_sig, F_S)\ + do_signature(index_partially_in_upper_range_sig, "(Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "I" \ + "J" \ + "J" \ + "Ljdk/internal/vm/vector/VectorSupport$IndexPartiallyInUpperRangeOperation;)" \ + "Ljdk/internal/vm/vector/VectorSupport$VectorMask;") \ + do_name(index_partially_in_upper_range_name, "indexPartiallyInUpperRange") \ + \ /* (2) Bytecode intrinsics */ \ \ do_intrinsic(_park, jdk_internal_misc_Unsafe, park_name, park_signature, F_RN) \ @@ -1319,7 +1329,7 @@ enum class vmIntrinsicID : int { __IGNORE_CLASS, __IGNORE_NAME, __IGNORE_SIGNATURE, __IGNORE_ALIAS) ID_LIMIT, - LAST_COMPILER_INLINE = _IndexVector, + LAST_COMPILER_INLINE = _IndexPartiallyInUpperRange, FIRST_MH_SIG_POLY = _invokeGeneric, FIRST_MH_STATIC = _linkToVirtual, LAST_MH_SIG_POLY = _linkToNative, diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp index 2399ab8bdbf..a6fa097bdee 100644 --- a/src/hotspot/share/opto/c2compiler.cpp +++ b/src/hotspot/share/opto/c2compiler.cpp @@ -782,6 +782,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_VectorExtract: case vmIntrinsics::_VectorMaskOp: case vmIntrinsics::_IndexVector: + case vmIntrinsics::_IndexPartiallyInUpperRange: return EnableVectorSupport; case vmIntrinsics::_blackhole: break; diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index 73a3566136f..a481045dc1f 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -725,6 +725,8 @@ bool LibraryCallKit::try_to_inline(int predicate) { return inline_vector_compress_expand(); case vmIntrinsics::_IndexVector: return inline_index_vector(); + case vmIntrinsics::_IndexPartiallyInUpperRange: + return inline_index_partially_in_upper_range(); case vmIntrinsics::_getObjectSize: return inline_getObjectSize(); diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp index 0293338ca82..97feb431dbf 100644 --- a/src/hotspot/share/opto/library_call.hpp +++ b/src/hotspot/share/opto/library_call.hpp @@ -357,6 +357,7 @@ class LibraryCallKit : public GraphKit { bool inline_vector_insert(); bool inline_vector_compress_expand(); bool inline_index_vector(); + bool inline_index_partially_in_upper_range(); Node* gen_call_to_svml(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2); diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 201d947264e..d088cfb1d0f 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -3006,3 +3006,131 @@ bool LibraryCallKit::inline_index_vector() { C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; } + +// public static +// > +// M indexPartiallyInUpperRange(Class mClass, Class eClass, int length, +// long offset, long limit, +// IndexPartiallyInUpperRangeOperation defaultImpl) +bool LibraryCallKit::inline_index_partially_in_upper_range() { + const TypeInstPtr* mask_klass = gvn().type(argument(0))->isa_instptr(); + const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); + const TypeInt* vlen = gvn().type(argument(2))->isa_int(); + + if (mask_klass == NULL || elem_klass == NULL || vlen == NULL || + mask_klass->const_oop() == NULL || elem_klass->const_oop() == NULL || !vlen->is_con()) { + if (C->print_intrinsics()) { + tty->print_cr(" ** missing constant: mclass=%s etype=%s vlen=%s", + NodeClassNames[argument(0)->Opcode()], + NodeClassNames[argument(1)->Opcode()], + NodeClassNames[argument(2)->Opcode()]); + } + return false; // not enough info for intrinsification + } + + if (!is_klass_initialized(mask_klass)) { + if (C->print_intrinsics()) { + tty->print_cr(" ** klass argument not initialized"); + } + return false; + } + + ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type(); + if (!elem_type->is_primitive_type()) { + if (C->print_intrinsics()) { + tty->print_cr(" ** not a primitive bt=%d", elem_type->basic_type()); + } + return false; // should be primitive type + } + + int num_elem = vlen->get_con(); + BasicType elem_bt = elem_type->basic_type(); + + // Check whether the necessary ops are supported by current hardware. + bool supports_mask_gen = arch_supports_vector(Op_VectorMaskGen, num_elem, elem_bt, VecMaskUseStore); + if (!supports_mask_gen) { + if (!arch_supports_vector(Op_VectorLoadConst, num_elem, elem_bt, VecMaskNotUsed) || + !arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, VecMaskNotUsed) || + !arch_supports_vector(Op_VectorMaskCmp, num_elem, elem_bt, VecMaskUseStore)) { + if (C->print_intrinsics()) { + tty->print_cr(" ** not supported: vlen=%d etype=%s", num_elem, type2name(elem_bt)); + } + return false; // not supported + } + + // Check whether the scalar cast operation is supported by current hardware. + if (elem_bt != T_LONG) { + int cast_op = is_integral_type(elem_bt) ? Op_ConvL2I + : (elem_bt == T_FLOAT ? Op_ConvL2F : Op_ConvL2D); + if (!Matcher::match_rule_supported(cast_op)) { + if (C->print_intrinsics()) { + tty->print_cr(" ** Rejected op (%s) because architecture does not support it", + NodeClassNames[cast_op]); + } + return false; // not supported + } + } + } + + Node* offset = argument(3); + Node* limit = argument(5); + if (offset == NULL || limit == NULL) { + if (C->print_intrinsics()) { + tty->print_cr(" ** offset or limit argument is NULL"); + } + return false; // not supported + } + + ciKlass* box_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); + assert(is_vector_mask(box_klass), "argument(0) should be a mask class"); + const TypeInstPtr* box_type = TypeInstPtr::make_exact(TypePtr::NotNull, box_klass); + + // We assume "offset > 0 && limit >= offset && limit - offset < num_elem". + // So directly get indexLimit with "indexLimit = limit - offset". + Node* indexLimit = gvn().transform(new SubLNode(limit, offset)); + Node* mask = NULL; + if (supports_mask_gen) { + mask = gvn().transform(VectorMaskGenNode::make(indexLimit, elem_bt, num_elem)); + } else { + // Generate the vector mask based on "mask = iota < indexLimit". + // Broadcast "indexLimit" to a vector. + switch (elem_bt) { + case T_BOOLEAN: // fall-through + case T_BYTE: // fall-through + case T_SHORT: // fall-through + case T_CHAR: // fall-through + case T_INT: { + indexLimit = gvn().transform(new ConvL2INode(indexLimit)); + break; + } + case T_DOUBLE: { + indexLimit = gvn().transform(new ConvL2DNode(indexLimit)); + break; + } + case T_FLOAT: { + indexLimit = gvn().transform(new ConvL2FNode(indexLimit)); + break; + } + case T_LONG: { + // no conversion needed + break; + } + default: fatal("%s", type2name(elem_bt)); + } + indexLimit = gvn().transform(VectorNode::scalar2vector(indexLimit, num_elem, Type::get_const_basic_type(elem_bt))); + + // Load the "iota" vector. + const TypeVect* vt = TypeVect::make(elem_bt, num_elem); + Node* iota = gvn().transform(new VectorLoadConstNode(gvn().makecon(TypeInt::ZERO), vt)); + + // Compute the vector mask with "mask = iota < indexLimit". + ConINode* pred_node = (ConINode*)gvn().makecon(TypeInt::make(BoolTest::lt)); + const TypeVect* vmask_type = TypeVect::makemask(elem_bt, num_elem); + mask = gvn().transform(new VectorMaskCmpNode(BoolTest::lt, iota, indexLimit, pred_node, vmask_type)); + } + Node* vbox = box_vector(mask, box_type, elem_bt, num_elem); + set_result(vbox); + C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); + return true; +} diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java index dc61572fc3f..a38b72a3b35 100644 --- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -210,6 +210,23 @@ public class VectorSupport { return defaultImpl.fromBits(bits, s); } + /* ============================================================================ */ + public interface IndexPartiallyInUpperRangeOperation> { + M apply(long offset, long limit); + } + + @IntrinsicCandidate + public static + > + M indexPartiallyInUpperRange(Class mClass, Class eClass, + int length, long offset, long limit, + IndexPartiallyInUpperRangeOperation defaultImpl) { + assert isNonCapturingLambda(defaultImpl) : defaultImpl; + return defaultImpl.apply(offset, limit); + } + /* ============================================================================ */ public interface ShuffleIotaOperation, SH extends VectorShuffle> { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java index 051e573939e..38be02fe70e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -195,24 +195,51 @@ abstract class AbstractMask extends VectorMask { return res; } - @Override + /*package-private*/ @ForceInline - public VectorMask indexInRange(int offset, int limit) { + VectorMask indexPartiallyInRange(int offset, int limit) { int vlength = length(); Vector iota = vectorSpecies().zero().addIndex(1); VectorMask badMask = checkIndex0(offset, limit, iota, vlength); - return this.andNot(badMask); + return badMask.not(); + } + + /*package-private*/ + @ForceInline + VectorMask indexPartiallyInRange(long offset, long limit) { + int vlength = length(); + Vector iota = vectorSpecies().zero().addIndex(1); + VectorMask badMask = checkIndex0(offset, limit, iota, vlength); + return badMask.not(); } @Override @ForceInline - public VectorMask indexInRange(long offset, long limit) { - int vlength = length(); - Vector iota = vectorSpecies().zero().addIndex(1); - VectorMask badMask = checkIndex0(offset, limit, iota, vlength); - return this.andNot(badMask); + public VectorMask indexInRange(int offset, int limit) { + if (offset < 0) { + return this.and(indexPartiallyInRange(offset, limit)); + } else if (offset >= limit) { + return vectorSpecies().maskAll(false); + } else if (limit - offset >= length()) { + return this; + } + return this.and(indexPartiallyInUpperRange(offset, limit)); } + @ForceInline + public VectorMask indexInRange(long offset, long limit) { + if (offset < 0) { + return this.and(indexPartiallyInRange(offset, limit)); + } else if (offset >= limit) { + return vectorSpecies().maskAll(false); + } else if (limit - offset >= length()) { + return this; + } + return this.and(indexPartiallyInUpperRange(offset, limit)); + } + + abstract VectorMask indexPartiallyInUpperRange(long offset, long limit); + /*package-private*/ @ForceInline AbstractVector diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java index 059adb451b6..12a6c80f21e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -685,6 +685,15 @@ final class Byte128Vector extends ByteVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Byte128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Byte128Mask) VectorSupport.indexPartiallyInUpperRange( + Byte128Mask.class, byte.class, VLENGTH, offset, limit, + (o, l) -> (Byte128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java index e70a4bebfa1..e2050716803 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -717,6 +717,15 @@ final class Byte256Vector extends ByteVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Byte256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Byte256Mask) VectorSupport.indexPartiallyInUpperRange( + Byte256Mask.class, byte.class, VLENGTH, offset, limit, + (o, l) -> (Byte256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java index b30955a91b0..a8a5875ea7b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -781,6 +781,15 @@ final class Byte512Vector extends ByteVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Byte512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Byte512Mask) VectorSupport.indexPartiallyInUpperRange( + Byte512Mask.class, byte.class, VLENGTH, offset, limit, + (o, l) -> (Byte512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java index 56824f34871..db3e9252944 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -669,6 +669,15 @@ final class Byte64Vector extends ByteVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Byte64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Byte64Mask) VectorSupport.indexPartiallyInUpperRange( + Byte64Mask.class, byte.class, VLENGTH, offset, limit, + (o, l) -> (Byte64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java index 984762ed7c8..0afdeab13dc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -655,6 +655,15 @@ final class ByteMaxVector extends ByteVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + ByteMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (ByteMaxMask) VectorSupport.indexPartiallyInUpperRange( + ByteMaxMask.class, byte.class, VLENGTH, offset, limit, + (o, l) -> (ByteMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java index cf774e3678f..2c5706fe2f0 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -646,6 +646,15 @@ final class Double128Vector extends DoubleVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Double128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Double128Mask) VectorSupport.indexPartiallyInUpperRange( + Double128Mask.class, double.class, VLENGTH, offset, limit, + (o, l) -> (Double128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java index 25738ae7ae7..3f4ee1bdc04 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -650,6 +650,15 @@ final class Double256Vector extends DoubleVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Double256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Double256Mask) VectorSupport.indexPartiallyInUpperRange( + Double256Mask.class, double.class, VLENGTH, offset, limit, + (o, l) -> (Double256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java index f4e999c808c..3f8211eef27 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -658,6 +658,15 @@ final class Double512Vector extends DoubleVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Double512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Double512Mask) VectorSupport.indexPartiallyInUpperRange( + Double512Mask.class, double.class, VLENGTH, offset, limit, + (o, l) -> (Double512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java index 510d739d976..9900c97f912 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -644,6 +644,15 @@ final class Double64Vector extends DoubleVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Double64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Double64Mask) VectorSupport.indexPartiallyInUpperRange( + Double64Mask.class, double.class, VLENGTH, offset, limit, + (o, l) -> (Double64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java index 877b14e24ba..32ff760fb36 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -643,6 +643,15 @@ final class DoubleMaxVector extends DoubleVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + DoubleMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (DoubleMaxMask) VectorSupport.indexPartiallyInUpperRange( + DoubleMaxMask.class, double.class, VLENGTH, offset, limit, + (o, l) -> (DoubleMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java index 972802387f3..5414be75607 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -650,6 +650,15 @@ final class Float128Vector extends FloatVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Float128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Float128Mask) VectorSupport.indexPartiallyInUpperRange( + Float128Mask.class, float.class, VLENGTH, offset, limit, + (o, l) -> (Float128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java index 79326ac6f9f..9194fbcde0e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -658,6 +658,15 @@ final class Float256Vector extends FloatVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Float256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Float256Mask) VectorSupport.indexPartiallyInUpperRange( + Float256Mask.class, float.class, VLENGTH, offset, limit, + (o, l) -> (Float256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java index 7e0489b9e6a..2e43f153b0c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -674,6 +674,15 @@ final class Float512Vector extends FloatVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Float512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Float512Mask) VectorSupport.indexPartiallyInUpperRange( + Float512Mask.class, float.class, VLENGTH, offset, limit, + (o, l) -> (Float512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java index c82adda2632..ccd75e18e06 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -646,6 +646,15 @@ final class Float64Vector extends FloatVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Float64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Float64Mask) VectorSupport.indexPartiallyInUpperRange( + Float64Mask.class, float.class, VLENGTH, offset, limit, + (o, l) -> (Float64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java index 4d2c1c17876..e5b4651531b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -643,6 +643,15 @@ final class FloatMaxVector extends FloatVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + FloatMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (FloatMaxMask) VectorSupport.indexPartiallyInUpperRange( + FloatMaxMask.class, float.class, VLENGTH, offset, limit, + (o, l) -> (FloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java index b51bd2e25c5..158686576f5 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -661,6 +661,15 @@ final class Int128Vector extends IntVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Int128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Int128Mask) VectorSupport.indexPartiallyInUpperRange( + Int128Mask.class, int.class, VLENGTH, offset, limit, + (o, l) -> (Int128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java index fe1471d8d32..4f251e43f1f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -669,6 +669,15 @@ final class Int256Vector extends IntVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Int256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Int256Mask) VectorSupport.indexPartiallyInUpperRange( + Int256Mask.class, int.class, VLENGTH, offset, limit, + (o, l) -> (Int256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java index 675aab8ef3a..4867c377a8a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -685,6 +685,15 @@ final class Int512Vector extends IntVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Int512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Int512Mask) VectorSupport.indexPartiallyInUpperRange( + Int512Mask.class, int.class, VLENGTH, offset, limit, + (o, l) -> (Int512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java index e876cd83576..2f44bfecf8f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -657,6 +657,15 @@ final class Int64Vector extends IntVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Int64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Int64Mask) VectorSupport.indexPartiallyInUpperRange( + Int64Mask.class, int.class, VLENGTH, offset, limit, + (o, l) -> (Int64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java index 2316da250d4..b79e73f52d6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -655,6 +655,15 @@ final class IntMaxVector extends IntVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + IntMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (IntMaxMask) VectorSupport.indexPartiallyInUpperRange( + IntMaxMask.class, int.class, VLENGTH, offset, limit, + (o, l) -> (IntMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java index ff08bd64b39..9b024f6e55c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -647,6 +647,15 @@ final class Long128Vector extends LongVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Long128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Long128Mask) VectorSupport.indexPartiallyInUpperRange( + Long128Mask.class, long.class, VLENGTH, offset, limit, + (o, l) -> (Long128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java index ed62368f40a..8a1844af370 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -651,6 +651,15 @@ final class Long256Vector extends LongVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Long256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Long256Mask) VectorSupport.indexPartiallyInUpperRange( + Long256Mask.class, long.class, VLENGTH, offset, limit, + (o, l) -> (Long256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java index 290369a6874..baec813f58e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -659,6 +659,15 @@ final class Long512Vector extends LongVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Long512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Long512Mask) VectorSupport.indexPartiallyInUpperRange( + Long512Mask.class, long.class, VLENGTH, offset, limit, + (o, l) -> (Long512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java index dfb438bf6ee..1d4110050f2 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -645,6 +645,15 @@ final class Long64Vector extends LongVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Long64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Long64Mask) VectorSupport.indexPartiallyInUpperRange( + Long64Mask.class, long.class, VLENGTH, offset, limit, + (o, l) -> (Long64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java index abcc2294d12..ecc2b393061 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -645,6 +645,15 @@ final class LongMaxVector extends LongVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + LongMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (LongMaxMask) VectorSupport.indexPartiallyInUpperRange( + LongMaxMask.class, long.class, VLENGTH, offset, limit, + (o, l) -> (LongMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java index 0cc80590473..1f587ca54a5 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -669,6 +669,15 @@ final class Short128Vector extends ShortVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Short128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Short128Mask) VectorSupport.indexPartiallyInUpperRange( + Short128Mask.class, short.class, VLENGTH, offset, limit, + (o, l) -> (Short128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java index b39b7c509c1..5e259b70b59 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -685,6 +685,15 @@ final class Short256Vector extends ShortVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Short256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Short256Mask) VectorSupport.indexPartiallyInUpperRange( + Short256Mask.class, short.class, VLENGTH, offset, limit, + (o, l) -> (Short256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java index c7a07c4d283..a6cbfb4f8e4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -717,6 +717,15 @@ final class Short512Vector extends ShortVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Short512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Short512Mask) VectorSupport.indexPartiallyInUpperRange( + Short512Mask.class, short.class, VLENGTH, offset, limit, + (o, l) -> (Short512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java index 4f0d8796482..b2a2ec11952 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -661,6 +661,15 @@ final class Short64Vector extends ShortVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + Short64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Short64Mask) VectorSupport.indexPartiallyInUpperRange( + Short64Mask.class, short.class, VLENGTH, offset, limit, + (o, l) -> (Short64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java index 6724ae88682..eaf99f61896 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -655,6 +655,15 @@ final class ShortMaxVector extends ShortVector { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + ShortMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (ShortMaxMask) VectorSupport.indexPartiallyInUpperRange( + ShortMaxMask.class, short.class, VLENGTH, offset, limit, + (o, l) -> (ShortMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index 69ff064ec53..14ba8d34161 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -928,6 +928,15 @@ final class $vectortype$ extends $abstractvectortype$ { return xor(m.not()); } + @Override + @ForceInline + /*package-private*/ + $masktype$ indexPartiallyInUpperRange(long offset, long limit) { + return ($masktype$) VectorSupport.indexPartiallyInUpperRange( + $masktype$.class, $type$.class, VLENGTH, offset, limit, + (o, l) -> ($masktype$) TRUE_MASK.indexPartiallyInRange(o, l)); + } + // Unary operations @Override diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java new file mode 100644 index 00000000000..da4842bc34a --- /dev/null +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java @@ -0,0 +1,101 @@ +// +// Copyright (c) 2023, Arm Limited. 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 org.openjdk.bench.jdk.incubator.vector; + +import java.util.concurrent.TimeUnit; +import jdk.incubator.vector.*; +import org.openjdk.jmh.annotations.*; + +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Benchmark) +@Warmup(iterations = 3, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +public class IndexInRangeBenchmark { + @Param({"7", "256", "259", "512"}) + private int size; + + private boolean[] mask; + + private static final VectorSpecies bspecies = VectorSpecies.ofLargestShape(byte.class); + private static final VectorSpecies sspecies = VectorSpecies.ofLargestShape(short.class); + private static final VectorSpecies ispecies = VectorSpecies.ofLargestShape(int.class); + private static final VectorSpecies lspecies = VectorSpecies.ofLargestShape(long.class); + private static final VectorSpecies fspecies = VectorSpecies.ofLargestShape(float.class); + private static final VectorSpecies dspecies = VectorSpecies.ofLargestShape(double.class); + + @Setup(Level.Trial) + public void Setup() { + mask = new boolean[512]; + } + + @Benchmark + public void byteIndexInRange() { + for (int i = 0; i < size; i += bspecies.length()) { + var m = bspecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } + + @Benchmark + public void shortIndexInRange() { + for (int i = 0; i < size; i += sspecies.length()) { + var m = sspecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } + + @Benchmark + public void intIndexInRange() { + for (int i = 0; i < size; i += ispecies.length()) { + var m = ispecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } + + @Benchmark + public void longIndexInRange() { + for (int i = 0; i < size; i += lspecies.length()) { + var m = lspecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } + + @Benchmark + public void floatIndexInRange() { + for (int i = 0; i < size; i += fspecies.length()) { + var m = fspecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } + + @Benchmark + public void doubleIndexInRange() { + for (int i = 0; i < size; i += dspecies.length()) { + var m = dspecies.indexInRange(i, size); + m.intoArray(mask, i); + } + } +}