Documentation change - GCC Internals The definition of MODES_TIEABLE_P is incorrect and has resulted in reduced optimisation for the avr target (and perhaps others) The definition is currently: "A C expression that is nonzero if a value of mode mode1 is accessible in mode mode2 without copying." This part would be ok but is then detailed as : "If HARD_REGNO_MODE_OK (r, mode1) and HARD_REGNO_MODE_OK (r, mode2) are always the same for any r, then MODES_TIEABLE_P (mode1, mode2) should be nonzero. If they differ for any r, you should define this macro to return zero unless some other mechanism ensures the accessibility of the value in a narrower mode." This second paragraph is too restrictive. MODES_TIEABLE_p may also be nonzero if r is accessible in any SMALLER mode. In the particular example of the avr target, word or larger registers are assigned even numbered registers ONLY. Byte registers have no such restriction. Because this does indeed fail the second paragraph criteria, MODE_TIEABLE_P has been set 0=FALSE preventing byte operations on the word register and uneeded register moves. It should have been set TRUE. I was tempted to report this as AVR target bug - but the code is not really the problem. Note that the definition is often included in target header files as well as gcc internal manual.
"If HARD_REGNO_MODE_OK (r, mode1) and HARD_REGNO_MODE_OK (r, mode2) are always the same for any r, then MODES_TIEABLE_P (mode1, mode2) should be nonzero. If they differ for any r, you should define this macro to return zero unless some other mechanism ensures the accessibility of the value in a narrower mode." In case of avr: if (mode1 != mode2) then HARD_REGNO_MODE_OK (r, mode1) != HARD_REGNO_MODE_OK (r, mode2) and hence MODES_TIEABLE_P (mode1, mode2) should be 0. [ But this is true only if we do not have other mechanism to access the value in narrower mode ]
Is this still an issue?
(In reply to Richard Biener from comment #2) > Is this still an issue? Reporter never replied; guess not