Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8278796: Incorrect behavior of FloatVector.withLane on X86 #196

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/hotspot/cpu/x86/x86.ad
Original file line number Diff line number Diff line change
Expand Up @@ -4333,7 +4333,8 @@ instruct insertF(vec dst, regF val, immU8 idx) %{
assert(vector_element_basic_type(this) == T_FLOAT, "sanity");
assert($idx$$constant < (int)vector_length(this), "out of bounds");

__ insertps($dst$$XMMRegister, $val$$XMMRegister, $idx$$constant);
uint x_idx = $idx$$constant & right_n_bits(2);
__ insertps($dst$$XMMRegister, $val$$XMMRegister, x_idx << 4);
%}
ins_pipe( pipe_slow );
%}
Expand All @@ -4353,13 +4354,13 @@ instruct vinsertF(vec dst, vec src, regF val, immU8 idx, vec vtmp) %{
uint y_idx = ($idx$$constant >> 2) & 1;
int vlen_enc = Assembler::AVX_256bit;
__ vextracti128($vtmp$$XMMRegister, $src$$XMMRegister, y_idx);
__ vinsertps($vtmp$$XMMRegister, $vtmp$$XMMRegister, $val$$XMMRegister, x_idx);
__ vinsertps($vtmp$$XMMRegister, $vtmp$$XMMRegister, $val$$XMMRegister, x_idx << 4);
__ vinserti128($dst$$XMMRegister, $src$$XMMRegister, $vtmp$$XMMRegister, y_idx);
} else {
assert(vlen == 16, "sanity");
uint y_idx = ($idx$$constant >> 2) & 3;
__ vextracti32x4($vtmp$$XMMRegister, $src$$XMMRegister, y_idx);
__ vinsertps($vtmp$$XMMRegister, $vtmp$$XMMRegister, $val$$XMMRegister, x_idx);
__ vinsertps($vtmp$$XMMRegister, $vtmp$$XMMRegister, $val$$XMMRegister, x_idx << 4);
__ vinserti32x4($dst$$XMMRegister, $src$$XMMRegister, $vtmp$$XMMRegister, y_idx);
}
%}
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Byte128VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
int i = 0;
static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -3264,13 +3264,16 @@ static void withByte128VectorTests(IntFunction<byte []> fa) {
byte[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.withLane(0, (byte)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (byte)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Byte256VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
int i = 0;
static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -3264,13 +3264,16 @@ static void withByte256VectorTests(IntFunction<byte []> fa) {
byte[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.withLane(0, (byte)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (byte)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Byte512VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
int i = 0;
static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -3264,13 +3264,16 @@ static void withByte512VectorTests(IntFunction<byte []> fa) {
byte[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.withLane(0, (byte)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (byte)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Byte64VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
int i = 0;
static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -3264,13 +3264,16 @@ static void withByte64VectorTests(IntFunction<byte []> fa) {
byte[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.withLane(0, (byte)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (byte)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
int i = 0;
static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -3269,13 +3269,16 @@ static void withByteMaxVectorTests(IntFunction<byte []> fa) {
byte[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.withLane(0, (byte)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (byte)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Double128VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
int i = 0;
static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2449,13 +2449,16 @@ static void withDouble128VectorTests(IntFunction<double []> fa) {
double[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
av.withLane(0, (double)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (double)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Double256VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
int i = 0;
static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2449,13 +2449,16 @@ static void withDouble256VectorTests(IntFunction<double []> fa) {
double[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
av.withLane(0, (double)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (double)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Double512VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
int i = 0;
static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2449,13 +2449,16 @@ static void withDouble512VectorTests(IntFunction<double []> fa) {
double[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
av.withLane(0, (double)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (double)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Double64VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
int i = 0;
static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2449,13 +2449,16 @@ static void withDouble64VectorTests(IntFunction<double []> fa) {
double[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
av.withLane(0, (double)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (double)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
int i = 0;
static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2454,13 +2454,16 @@ static void withDoubleMaxVectorTests(IntFunction<double []> fa) {
double[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
av.withLane(0, (double)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (double)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
Expand Down
15 changes: 9 additions & 6 deletions test/jdk/jdk/incubator/vector/Float128VectorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction
}
}

static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
int i = 0;
static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) {
int i = start;
try {
for (; i < a.length; i += 1) {
for (; i < end; i += 1) {
if(i%SPECIES.length() == index) {
Assert.assertEquals(r[i], element);
} else {
Expand Down Expand Up @@ -2459,13 +2459,16 @@ static void withFloat128VectorTests(IntFunction<float []> fa) {
float[] r = fr.apply(SPECIES.length());

for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.withLane(0, (float)4).intoArray(r, i);
av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i);
}
}

assertInsertArraysEquals(r, a, (float)4, 0);

for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
static boolean testIS_DEFAULT(float a) {
return bits(a)==0;
Expand Down
Loading