Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/superword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,8 @@ static bool can_subword_truncate(Node* in, const Type* type) {
case Op_RotateRight:
case Op_RotateLeft:
case Op_PopCountI:
case Op_ReverseBytesS:
case Op_ReverseBytesUS:
case Op_ReverseBytesI:
case Op_ReverseI:
case Op_CountLeadingZerosI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/*
* @test
* @bug 8350177 8362171
* @bug 8350177 8362171 8369881
* @summary Ensure that truncation of subword vectors produces correct results
* @library /test/lib /
* @run driver compiler.vectorization.TestSubwordTruncation
Expand Down Expand Up @@ -351,6 +351,57 @@ public void checkTestByteReverse(Object[] vals) {
}
}

@Test
@IR(counts = { IRNode.STORE_VECTOR, "=0" })
@Arguments(setup = "setupByteArray")
public Object[] testByteReverseBytesS(byte[] in) {
byte[] res = new byte[SIZE];
for (int i = 0; i < SIZE; i++) {
res[i] = (byte)Short.reverseBytes(in[i]);
}

return new Object[] { in, res };
}

@Check(test = "testByteReverseBytesS")
public void checkTestByteReverseBytesS(Object[] vals) {
byte[] in = (byte[]) vals[0];
byte[] res = (byte[]) vals[1];

for (int i = 0; i < SIZE; i++) {
byte val = (byte)Short.reverseBytes(in[i]);
if (res[i] != val) {
throw new IllegalStateException("Expected " + val + " but got " + res[i] + " for " + in[i]);
}
}
}

@Test
@IR(counts = { IRNode.STORE_VECTOR, "=0" })
@Arguments(setup = "setupByteArray")
public Object[] testByteReverseBytesUS(byte[] in) {
byte[] res = new byte[SIZE];
for (int i = 0; i < SIZE; i++) {
res[i] = (byte)Character.reverseBytes((char)in[i]);
}

return new Object[] { in, res };
}

@Check(test = "testByteReverseBytesUS")
public void checkTestByteReverseBytesUS(Object[] vals) {
byte[] in = (byte[]) vals[0];
byte[] res = (byte[]) vals[1];

for (int i = 0; i < SIZE; i++) {
byte val = (byte)Character.reverseBytes((char)in[i]);
if (res[i] != val) {
throw new IllegalStateException("Expected " + val + " but got " + res[i] + " for " + in[i]);
}
}
}


@Test
@IR(counts = { IRNode.STORE_VECTOR, "=0" })
@Arguments(setup = "setupByteArray")
Expand Down