> >> Did you see the failures even after your mips_regno_mode_ok_for_base_p > >> change? LRA should know how to reload a "W" address. > > > > Yes but I realize there is more. It fails because $sp is now included > > in BASE_REG_CLASS and "W" is based on it. However, I suppose that > > it would be too eager to say it is wrong and likely there is something > > missing > > in LRA if we want to keep all alternatives. Currently there is no check > > if a reloaded operand has a valid address, use of $sp in lbu/lhu cases. > > Even if we added extra checks we are less likely to benefit as we need > > to reload the base into register. > > Not sure what you mean, sorry. "W" exists specifically to exclude > $sp-based and $pc-based addresses. LRA AFAIK should already be able > to reload addresses that are valid in the TARGET_LEGITIMATE_ADDRESS_P > sense but which do not match the constraints for a particular insn. > > Can you remember one of the tests that fails?
I couldn't trigger the problem with the original testcase but found another one that reveals it. The following needs to compiled with -mips32r2 -mips16 -Os: struct { int addr; } c; struct command { int args[1]; }; unsigned short a; fn1 (struct command *p1) { unsigned short d; d = fn2 (); a = p1->args[0]; fn3 (a); if (c.addr) { fn4 (p1->args[0]); return; } (&c)->addr = fn5 (); fn6 (d); } Not sure how the constraint would/should exclude $sp-based address in LRA. In this particular case, a spilled pseudo is changed to memory giving the following RTL form: (insn 30 29 31 4 (set (reg:SI 4 $4) (and:SI (mem/c:SI (plus:SI (reg/f:SI 78 $frame) (const_int 16 [0x10])) [7 %sfp+16 S4 A32]) (const_int 65535 [0xffff]))) shell.i:17 161 {*andsi3_mips16} (expr_list:REG_DEAD (reg:SI 194 [ D.1469 ]) (nil))) The operand 1 during alternative selection is not marked as a bad operand as it is a memory operand. $frame appears to be fine as it could be eliminated later to hard register. No reloads are inserted for the instructions concerned. Unless, $frame should be temporarily eliminated and then a reload would be inserted? Regards, Robert