When left-shifting the incoming VL parameter, it may cause overflow
when the vl >= 0x80000000, resulting in the wrong VL length setting.
For example this code and the output:
#include <riscv_vector.h>
vint64m1_t
test (vint64m1_t a, int64_t b)
{
return vslide1up_vx_i64m1(a, b, 0x80000000);
}
/* assembly output:
test:
vsetivli zero, 0, e32, m1, ta, mu
vslide1up.vx v9, v8, a1
vslide1up.vx v8, v9, a0
ret
*/The bug was caused by this commit.
MinSize / RISCV::RVVBitsPerBlock; is equal to LMUL and you using this equation to prevent screw up for fractional LMUL, but it's kind of hard to understand at first impression, so I would suggest you can add an util function here and use LMUL explicitly like that:
And
it would improve readability