--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
So in particular
for (ref = DF_INSN_UID_DEFS (insn_uid); ref; ref = DF_REF_NEXT_LOC (ref))
if (!HARD_REGISTER_P (DF_REF_REG (ref)))
for (def = DF_REG_DEF_CHAIN (DF_REF_REGNO (ref));
def = DF_REF_NEXT_REG (def))
analyze_register_chain (candidates, ref);
looks odd since that iterates over all defs in insn_uid, then over
all defs of that register everywhere else in the function and
analyze_register_chain then iterating over the corresponding def->use
chain. I'd say the iteration over all defs everywhere else is
not necessary and it should be simply
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Uh, all other DF_REG_REG_CHAIN uses need to be updated as well I guess, how
we convert defs and uses seems to be a slight mess :/ I'm going to try
to rewrite this part to
for insn in insns
for def in insn
if def in defs_conv
replace def in insn with subreg of new pseudo from new defs-map
emit copy from new def to original scalar def
replace def with subreg
for use in insn
if use in defs_conv & ~defs
replace use in insn with subreg of new pseudo from new defs-map
emit copy from old scalar def to new def
replace use with subreg [of new pseudo from new defs-map]
that should also support chains where not all defs of a pseudo are part
of the chain. Since we have ud and du chains we can use those more.
* config/i386/i386-features.h (general_scalar_chain::defs_map):
(general_scalar_chain::convert_reg): Adjust signature.
* config/i386/i386-features.c (scalar_chain::add_insn): Do not
iterate over all defs of a reg.
(general_scalar_chain::make_vector_copies): Populate defs_map,
place copy only after defs that are used as vectors in the chain.
(general_scalar_chain::convert_reg): Emit a copy for a specific
def in a specific instruction.
(general_scalar_chain::convert_op): All reg uses are converted here.
(general_scalar_chain::convert_insn): Emit copies for scalar
uses of defs here. Replace uses with the copies we created.
Replace and convert the def. Adjust REG_DEAD notes, remove
(general_scalar_chain::convert_registers): Only handle copies
into the chain here.