Quoting Eric Botcazou <ebotca...@adacore.com>:
The patch is OK on principle, but can you factor out the common code? The endings of move2add_use_add2_insn and move2add_use_add3_insn are identical so it would be nice to have e.g. a record_reg_value helper function and call it from there. Similarly, the 3 new checks look strictly identical.
Looking into sharing the code with sites that perform essentially the same function but look somewhat different, I see there's a problem with using only reg_set_luid to indicate the consistency of a multi-hard-reg-value in these other contexts. For values that are use a base register, the reg_set_luid is the same as for the base register; for constants, it is the same for all constants set since the last label. Say we have reg size 8 bit, base r0, and then (set reg:HI 2 (plus:SI (reg:HI 0) (const_int 500)) ... (set reg:HI 3 (plus:SI (reg:HI 0) (const_int 500)) Now how do we tell that the value in r2 is no longer valid? As the example shows, trying to replicate the recorded value across all hard regs is pointless, as we still need to make sure that we have a still-valid start register. OTOH, this ties in nicely with setting the mode of subsequent registers to VOIDmode. We can verify the mode to make sure there was no more recent set of any constituent register. The check of the extra luids thus becomes superflous, as becomes the set. This logic relies on multi-hard register regs to be allocated contigously... But if we'd want to change that, there'd be a lot more code that would need changing.