8262989: Vectorize VectorShuffle checkIndexes, wrapIndexes and laneIsValid methods

Reviewed-by: psandoz
This commit is contained in:
Sandhya Viswanathan 2021-03-04 21:25:03 +00:00
parent c8b23e22f2
commit 718d4d487c
8 changed files with 34 additions and 36 deletions

@ -123,24 +123,23 @@ abstract class AbstractShuffle<E> extends VectorShuffle<E> {
if (VectorIntrinsics.VECTOR_ACCESS_OOB_CHECK == 0) {
return this;
}
// FIXME: vectorize this
for (int index : reorder()) {
if (index < 0) {
throw checkIndexFailed(index, length());
}
Vector<E> shufvec = this.toVector();
VectorMask<E> vecmask = shufvec.compare(VectorOperators.LT, vspecies().zero());
if (vecmask.anyTrue()) {
byte[] reorder = reorder();
throw checkIndexFailed(reorder[vecmask.firstTrue()], length());
}
return this;
}
@ForceInline
public final VectorShuffle<E> wrapIndexes() {
// FIXME: vectorize this
byte[] reorder = reorder();
int length = reorder.length;
for (int index : reorder) {
if (index < 0) {
return wrapAndRebuild(reorder);
}
Vector<E> shufvec = this.toVector();
VectorMask<E> vecmask = shufvec.compare(VectorOperators.LT, vspecies().zero());
if (vecmask.anyTrue()) {
// FIXME: vectorize this
byte[] reorder = reorder();
return wrapAndRebuild(reorder);
}
return this;
}
@ -166,16 +165,8 @@ abstract class AbstractShuffle<E> extends VectorShuffle<E> {
@ForceInline
public final VectorMask<E> laneIsValid() {
// FIXME: vectorize this
byte[] reorder = reorder();
int length = reorder.length;
boolean[] bits = new boolean[length];
for (int i = 0; i < length; i++) {
if (reorder[i] >= 0) {
bits[i] = true;
}
}
return vspecies().dummyVector().maskFromArray(bits);
Vector<E> shufvec = this.toVector();
return shufvec.compare(VectorOperators.GE, vspecies().zero());
}
@Override

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2144,7 +2144,8 @@ public abstract class ByteVector extends AbstractVector<Byte> {
S shuffle,
ByteVector v) {
VectorMask<Byte> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
ByteVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, byte.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2057,7 +2057,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
S shuffle,
DoubleVector v) {
VectorMask<Double> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
DoubleVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, double.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2069,7 +2069,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
S shuffle,
FloatVector v) {
VectorMask<Float> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
FloatVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, float.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2143,7 +2143,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
S shuffle,
IntVector v) {
VectorMask<Integer> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
IntVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, int.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2014,7 +2014,8 @@ public abstract class LongVector extends AbstractVector<Long> {
S shuffle,
LongVector v) {
VectorMask<Long> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
LongVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, long.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2144,7 +2144,8 @@ public abstract class ShortVector extends AbstractVector<Short> {
S shuffle,
ShortVector v) {
VectorMask<Short> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
ShortVector r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, short.class, length(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -2413,7 +2413,8 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
S shuffle,
$abstractvectortype$ v) {
VectorMask<$Boxtype$> valid = shuffle.laneIsValid();
S ws = shuffletype.cast(shuffle.wrapIndexes());
@SuppressWarnings("unchecked")
S ws = (S) shuffle.wrapIndexes();
$abstractvectortype$ r0 =
VectorSupport.rearrangeOp(
getClass(), shuffletype, $type$.class, length(),