It seems the issue is we didn't set "vlmul" ?
Can we do that:
int max_sew = MAX (prev.get_sew (), next.get_sew ());
prev.set_sew (max_sew);
prev.set_vlmul (calculate_vlmul (...));
prev.set_ratio (calculate_ratio (prev.get_sew (), prev.get_vlmul ()));
What we could do is
prev.set_ratio (calculate_ratio (prev.get_sew (), prev.get_vlmul ()));
prev.set_vlmul (calculate_vlmul (prev.get_sew (), prev.get_ratio ()));
Ratio needs to be corrected first according to old LMUL and new SEW. Then we
can adjust LMUL. Otherwise we'd set the wrong LMUL according to the old ratio.
But I find the recalculation more confusing than just re-using the values from
the vsetvl with larger SEW.
--
Regards
Robin