> As reported in pr57540, gcc chooses bad address mode, resulting in A) > invariant part of address expression is not kept or hoisted; b) additional > computation which should be encoded in address expression. The reason is > when gcc runs into "addr+offset" (which is invalid) during expanding, it > pre-computes the entire address and accesses memory unit using "MEM[reg]". > Yet we can force addr into register and try to generate "reg+offset" which > is valid for targets like ARM. By doing this, we can: > 1) keep addr in loop invariant form and hoist it later; > 2) saving additional computation by taking advantage of scaled addressing > mode;
Does the invalid address not go through arm_legitimize_address from here? /* Perform machine-dependent transformations on X in certain cases. This is not necessary since the code below can handle all possible cases, but machine-dependent transformations can make better code. */ { rtx orig_x = x; x = targetm.addr_space.legitimize_address (x, oldx, mode, as); if (orig_x != x && memory_address_addr_space_p (mode, x, as)) goto done; } -- Eric Botcazou