> The register replacement is done by gcse but the cse pass invoked from gcse > modifies the REG_EQUAL note. The limited scope of cse compared to gcse is > probably the reason why the information put into the insn note isn't > helpful. The REG_EQUAL note added to insn 2308 seems to be particularly > pointless. > > [...] > > The cleanup cse pass called in gcse.c:6676 then modifies the REG_EQUAL > note. cse calls fold_rtx for the REG_EQUAL note in cse.c:4936 looking for a > replacement of the symbol_ref. cse only sees that this value has already > been copied to r974 and puts that register into the REG_EQUAL note.
Interesting game, thanks for the explanation. > It is only conditionally invariant since it is set in the loop body - to a > constant value though. set_in_loop is -2 and loop_invariant_p returns 2 as > expected. OK. Then would it be enough to weaken the condition of the removal test to if (loop_invariant_p (loop, ...) != 1) in order to solve your problem? -- Eric Botcazou