http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45233
--- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> 2011-11-09 10:03:31 UTC --- well, I was trying to be too complicated - we should just avoid trying to do the substitution unless we can see the var in the TU. When this is done: Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 181150) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -6169,6 +6169,7 @@ rs6000_legitimize_reload_address (rtx x, enum mach #if TARGET_MACHO && DEFAULT_ABI == ABI_DARWIN && (flag_pic || MACHO_DYNAMIC_NO_PIC_P) + && machopic_symbol_defined_p (x) #else && DEFAULT_ABI == ABI_V4 && !flag_pic .. the test-case generates beautiful (i.e. what one would have generated by hand) asm. reg-strapped on trunk (although there's a lot of noise on trunk right now because of recent changes) - doing 4.6 branch now. will post to patches if the 4.6 regstrap is also OK. ==== As an aside (non-Darwin comment - since powerpc-eabisim does exactly the same). It's not obvious why the perfectly sensible RTL pre-combine is thrown away and the process started over (I'm guessing it's because the asm insn has a zero computed cost). Effectively (to my untutored eye), we end up rebuilding what was there before combine from the reload ...