https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104117
--- Comment #11 from Iain Sandoe <iains at gcc dot gnu.org> --- [this is reproducible on a cross] @vmakarov - I need some help understanding the intent of this code in "lra-constraints.c"[3552-3614 in the 11.x branch, where i can see this bug up to r11-8936-gbe64e725111fdb9] as noted above that is only because subsequent patches have made the problem latent in the test code. The code is triggered by (2) here (LRA has decided to force the const to men). 2) the address is an invalid symbolic address created by force_const_to_mem. <snip> so the address "SYMBOL_REF("*LCNN") is not valid for PIC code on this platform... .. but the code below seems to work on the principle that putting the invalid addr into a register is enough to make it valid - but actually what is needed is for the target to add a wrapper to the SYMBOL_REF - however, I do not see the target's address legitimiser code being called after this - or during this, We seem to be unconditionally building R = HIGH (invalid) R' = R + LO_SUM(invalid) the second valid_address_p() has the register as the tested object, which will be OK even tho the lo_sum constant is not? IFF I hack the code to punt after the first valid_address_p() call fails, it fixes the bug, but I'm not at all sure that this is the right solution - or what effect it might have elsewhere. Perhaps this target is the only LO_SUM one with a wrapper on addresses (but OTOH, I could imagine TLS symbols with similar properties). ---- new_reg = lra_create_new_reg (Pmode, NULL_RTX, cl, "addr"); if (HAVE_lo_sum) { /* addr => lo_sum (new_base, addr), case (2) above. */ insn = emit_insn (gen_rtx_SET (new_reg, gen_rtx_HIGH (Pmode, copy_rtx (addr)))); code = recog_memoized (insn); if (code >= 0) { *ad.inner = gen_rtx_LO_SUM (Pmode, new_reg, addr); if (!valid_address_p (op, &ad, cn)) { /* Try to put lo_sum into register. */ insn = emit_insn (gen_rtx_SET (new_reg, gen_rtx_LO_SUM (Pmode, new_reg, addr))); code = recog_memoized (insn); if (code >= 0) { *ad.inner = new_reg; if (!valid_address_p (op, &ad, cn)) { *ad.inner = addr; code = -1; } } } } if (code < 0) delete_insns_since (last);