Skip to content
Permalink
Browse files
8262989: Vectorize VectorShuffle checkIndexes, wrapIndexes and laneIs…
…Valid methods

Reviewed-by: psandoz
  • Loading branch information
Sandhya Viswanathan committed Mar 4, 2021
1 parent c8b23e2 commit 718d4d487c55971c568a1d3e29f70c2fb5a11034
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 36 deletions.
@@ -123,24 +123,23 @@ public final VectorShuffle<E> checkIndexes() {
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 @@ public final VectorShuffle<E> wrapAndRebuild(byte[] oldReorder) {

@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 @@ ByteVector rearrangeTemplate(Class<S> shuffletype,
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 @@ DoubleVector rearrangeTemplate(Class<S> shuffletype,
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 @@ FloatVector rearrangeTemplate(Class<S> shuffletype,
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 @@ IntVector rearrangeTemplate(Class<S> shuffletype,
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 @@ LongVector rearrangeTemplate(Class<S> shuffletype,
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 @@ ShortVector rearrangeTemplate(Class<S> shuffletype,
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(),

0 comments on commit 718d4d4

Please sign in to comment.