In the code guarded by double_reg_address_ok, reload is trying to create
a valid offsetable base+index address. Given the above, I think the
*_REG_CLASS group of macros -- the "how do I make this address valid?"
macros -- ought to be directly telling reload what class of index
register is allowed in such an address. And the backend should answer
NO_REGS if it doesn't allow any register to be used like that,
much as EXTRA_CONSTRAINT would return NO_REGS for register classes
that aren't available with the current command-line options.
An obvious way do to this would be add an "offsetable_p" argument to
MODE_INDEX_REG_CLASS and mode_reg_class (i.e. the addresses.h function
in my patch that wraps the target macros).
This approach seems far cleaner to me. The current code, and the
code after your patch, is jumping through hoops trying to guess what
constitutes an offsetable base+index address, and in which contexts
such an address is valid. But this is information that the backend knows
a priori. I think adding an "offsetable_p" argument to MODE_INDEX_REG_CLASS
would be: