> The SET to a subreg like (subreg:V2SI (reg:V4SI x) 0) is causing problems > here. > REG x is spilt onto the stack. > > This is a partial assignment to REG x. Our current RISC-V implementation uses > the word size (8 bytes or 4 bytes) as the natural size of the constant-sized > vector modes, so the aforementioned subreg SET is expected to preserve the > upper > bits of REG x. `record_subregs_of_mode` finds that the upper part cannot be > preserved (which part of code was introduced in 2692b5c), and thus the REG x > is > assigned NO_REGS, hence the spilling.
Yes, that's all a bit convoluted and (common) vector subreg handling still has rough edges that need polishing. In ira/lra in particular. What you could still try is a paradoxical subreg like (subreg:vmode (reg:half_mode)) as source for the slide. That will likely get you one redundant register copy, though :/ I think last time I checked that was due to a missed case in lra's "risky transformation" spill logic which didn't take subregs into account. Not entirely trivial to fix, but might not be terrible either. So I suggest we move forward here. A naming nit, still: > + unsigned int wide_elen = GET_MODE_BITSIZE (GET_MODE_INNER (vmode)) * > 2; > + scalar_int_mode smode = int_mode_for_size (wide_elen, 0).require (); > + scalar_int_mode smode_narrow > + = int_mode_for_size (GET_MODE_BITSIZE (GET_MODE_INNER (vmode)), 0) > + .require (); > + machine_mode wider_vmode = get_vector_mode (smode, vlen / 2).require > (); > + machine_mode half_len_mode > + = get_vector_mode (smode_narrow, vlen / 2).require (); > + unsigned int shift_amt = even ? 0 : wide_elen / 2; wide_elen / 2 is just elen? So I suggest to split that out and use wide_elen = elen * 2; Also maybe rename it to elen2x oder double_elen or so. We're not actually widening here. Similar for the naming of the related modes. The comment should specify that for VLS modes subregs larger than what riscv_regmode_natural_size allows cause a memory roundtrip and link to the PR you opened. Also, please describe the approach in rough terms in the comment. Maybe we also want to open a PR for the "risky transformation" case I mentioned. I can do that. -- Regards Robin
