https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121334
--- Comment #1 from Robin Dapp <rdapp at gcc dot gnu.org> --- We actually don't consider the constant legitimate via riscv_legitimate_constant_p but expr.cc says if (!targetm.legitimate_constant_p (mode, y)) { y = force_const_mem (mode, y); /* If the target's cannot_force_const_mem prevented the spill, assume that the target's move expanders will also take care of the non-legitimate constant. */ if (!y) y = y_cst; our cannot_force_const_mem prohibits spilling to memory because we can't handle VLA vectors: /* There's no way to calculate VL-based values using relocations. */ subrtx_iterator::array_type array; FOR_EACH_SUBRTX (iter, array, x, ALL) if (GET_CODE (*iter) == CONST_POLY_INT) return true; That leaves us with a non-spillable const_vector that we have no expander for. So from my current understanding of it there is no way around writing one.