https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78617

--- Comment #2 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
I've tracked down the problem to do_remat:

The function scans instruction forward in each basic block and looks for a
candidate to use for rematerialization. To check whether the candidate is used,
it verify that the candidate does not clobber a register that is live at the
point of rematerialization. The function thus keeps track of live registers but
the initialization of live registers at the beginning of a basic block loop
looks suspicious to me:

REG_SET_TO_HARD_REG_SET (live_hard_regs, df_get_live_out (bb));

I see two problems with that. The first one is that it should use
df_get_live_in (bb) since this is a forward scan (as attested by FOR_BB_INSNS
(bb, insn) and the way the live_hard_regs updating logic is). The second
problem is that REG_SET_TO_HARD_REG_SET will only care about hard registers in
the bitmap and will not look at reg_renumber for the pseudo register that are
live yet all the logic after that uses get_hard_regs that does consider
reg_renumber for pseudo registers.

Fixing both solve the issue with the testcase, I am now running a regression
test to see if I've done something foulish that breaks half the testsuite.

Reply via email to