Skip to content

Commit d85cd10

Browse files
authored
Merge pull request #1971 from riscv-software-src/strict-vsetvtype
Set vill for vsetvli x0, x0, [different SEW/LMUL ratio]
2 parents 77ea9de + b5e15e3 commit d85cd10

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

riscv/vector_unit.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ void vectorUnit_t::vectorUnit_t::reset()
2929

3030
reg_t vectorUnit_t::vectorUnit_t::set_vl(int rd, int rs1, reg_t reqVL, reg_t newType)
3131
{
32-
int new_vlmul = 0;
3332
if (vtype->read() != newType) {
33+
int new_vlmul = int8_t(extract64(newType, 0, 3) << 5) >> 5;
34+
auto old_vlmax = vlmax;
35+
3436
vsew = 1 << (extract64(newType, 3, 3) + 3);
35-
new_vlmul = int8_t(extract64(newType, 0, 3) << 5) >> 5;
3637
vflmul = new_vlmul >= 0 ? 1 << new_vlmul : 1.0 / (1 << -new_vlmul);
3738
vlmax = (VLEN/vsew) * vflmul;
3839
vta = extract64(newType, 6, 1);
3940
vma = extract64(newType, 7, 1);
4041

4142
vill = !(vflmul >= 0.125 && vflmul <= 8)
4243
|| vsew > std::min(vflmul, 1.0f) * ELEN
43-
|| (newType >> 8) != 0;
44+
|| (newType >> 8) != 0
45+
|| (rd == 0 && rs1 == 0 && old_vlmax != vlmax);
4446

4547
if (vill) {
4648
vlmax = 0;
@@ -54,7 +56,7 @@ reg_t vectorUnit_t::vectorUnit_t::set_vl(int rd, int rs1, reg_t reqVL, reg_t new
5456
if (vlmax == 0) {
5557
vl->write_raw(0);
5658
} else if (rd == 0 && rs1 == 0) {
57-
vl->write_raw(std::min(vl->read(), vlmax));
59+
; // retain current VL
5860
} else if (rd != 0 && rs1 == 0) {
5961
vl->write_raw(vlmax);
6062
} else if (rs1 != 0) {

0 commit comments

Comments
 (0)