Skip to content

8361836: RISC-V: Relax min vector length to 32-bit for short vectors #26239

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
34 changes: 24 additions & 10 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1985,17 +1985,31 @@ int Matcher::max_vector_size(const BasicType bt) {
}

int Matcher::min_vector_size(const BasicType bt) {
int max_size = max_vector_size(bt);
// Limit the min vector size to 8 bytes.
int size = 8 / type2aelembytes(bt);
if (bt == T_BYTE) {
// To support vector api shuffle/rearrange.
size = 4;
} else if (bt == T_BOOLEAN) {
// To support vector api load/store mask.
size = 2;
int size;
switch(bt) {
case T_BOOLEAN:
// Load/store a vector mask with only 2 elements for vector types
// such as "2I/2F/2L/2D".
size = 2;
break;
case T_BYTE:
// Generate a "4B" vector, to support vector cast between "8B/16B"
// and "4S/4I/4L/4F/4D".
size = 4;
break;
case T_SHORT:
// Generate a "2S" vector, to support vector cast between "4S/8S"
// and "2I/2L/2F/2D".
size = 2;
break;
default:
// Limit the min vector length to 64-bit.
size = 8 / type2aelembytes(bt);
// The number of elements in a vector should be at least 2.
size = MAX2(size, 2);
}
if (size < 2) size = 2;

int max_size = max_vector_size(bt);
return MIN2(size, max_size);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,17 @@ public class TestCastMethods {
// from S 64
// to X 64
makePair(SSPEC64, BSPEC64),
makePair(SSPEC64, ISPEC64),
makePair(SSPEC64, ISPEC64, true),
makePair(SSPEC64, FSPEC64),
// to X 128
makePair(SSPEC64, BSPEC128),
makePair(SSPEC64, ISPEC128),
makePair(SSPEC64, ISPEC128, true),
makePair(SSPEC64, LSPEC128),
makePair(SSPEC64, LSPEC128, true),
makePair(SSPEC64, FSPEC128),
makePair(SSPEC64, DSPEC128),
// to X 256
makePair(SSPEC64, BSPEC256),
makePair(SSPEC64, ISPEC256),
Expand All @@ -156,7 +162,10 @@ public class TestCastMethods {
makePair(SSPEC128, BSPEC128),
makePair(SSPEC128, ISPEC128),
makePair(SSPEC128, ISPEC128, true),
makePair(SSPEC128, LSPEC128),
makePair(SSPEC128, LSPEC128, true),
makePair(SSPEC128, FSPEC128),
makePair(SSPEC128, DSPEC128),
// to X 256
makePair(SSPEC128, BSPEC256),
makePair(SSPEC128, ISPEC256),
Expand Down Expand Up @@ -228,6 +237,7 @@ public class TestCastMethods {
// ====== from I ======
// from I 64
// to X 64
makePair(ISPEC64, SSPEC64),
makePair(ISPEC64, FSPEC64),
// to X 128
makePair(ISPEC64, LSPEC128),
Expand Down Expand Up @@ -299,10 +309,12 @@ public class TestCastMethods {
// ====== from L ======
// from L 128
// to X 64
makePair(LSPEC128, SSPEC64),
makePair(LSPEC128, ISPEC64),
makePair(LSPEC128, FSPEC64),
makePair(LSPEC128, DSPEC64),
// to X 128
makePair(LSPEC128, SSPEC128),
makePair(LSPEC128, ISPEC128),
makePair(LSPEC128, FSPEC128),
makePair(LSPEC128, DSPEC128),
Expand Down Expand Up @@ -369,6 +381,7 @@ public class TestCastMethods {
// ====== from F ======
// from F 64
// to X 64
makePair(FSPEC64, SSPEC64),
makePair(FSPEC64, ISPEC64),
// to X 128
makePair(FSPEC64, ISPEC128),
Expand Down Expand Up @@ -433,10 +446,12 @@ public class TestCastMethods {
// ====== from D ======
// from D 128
// to X 64
makePair(DSPEC128, SSPEC64),
makePair(DSPEC128, ISPEC64),
makePair(DSPEC128, LSPEC64),
makePair(DSPEC128, FSPEC64),
// to X 128
makePair(DSPEC128, SSPEC128),
makePair(DSPEC128, ISPEC128),
makePair(DSPEC128, LSPEC128),
makePair(DSPEC128, FSPEC128),
Expand Down