On 2026-09-09 3:04 p.m., Jeff Law wrote: > > > On 9/9/26 11:36 AM, John David Anglin wrote: >> Tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11. >> >> Fixes spill failure report in PR rtl-optimization/127142. >> >> Committed to trunk. >> >> Dave >> --- >> >> hppa: Reduce r1 register pressure >> >> I have seen a few compiles fail where LRA is unable to find a >> register to spill. If we don't need a spill, the best way to >> load the high part of a symbolic operand is to use the addil >> instruction. It uses register r1 as its destinition operand. >> In the best case, the linker can remove unnecessary addil >> instructions. >> >> However, when there are multiple symbolic loads in a function, >> LRA is sometimes unable to find a register to spill. The >> original reload was better at handling r1 register spills. >> >> This change adds an additional alternative using a ldil/addl >> sequence which avoids using the r1 register. This is less >> costly than spilling r1. >> >> There is one PIC insn that I didn't update. When PIC code is >> linked into non PIC executable, the linker needs to change the >> PIC register, r19, to the DP register, r27. Currently, GNU ld >> only supports doing this with addil instructions. >> >> 2026-09-09 John David Anglin <[email protected]> >> >> gcc/ChangeLog: >> >> PR rtl-optimization/127142 >> * config/pa/pa.md: Add alternatives using ldil/addl >> sequence to various insns to load the high part of >> a symbolic operand. > It's been eons, but IIRC there were scenarios where the HP linker would take > a DP relative address and make it an absolute address. It was not > an optimization but a correctness thing. The HP linker would't do that for > ldil based addresses. The net is that ldil+addl is not always an > equivalent sequence.
Wasn't aware of that but the 32-bit HP-UX port is dead. I've tested change with 64-bit HP-UX and it was okay. It also works okay on 32-bit linux with GNU ld. The 32-bit GNU linux linker doesn't do this although it does change r19 to dp in non PIC links with PIC objects. I have a linker patch which I hope will allow it to perform this substitution with a ldil/addl sequence but it needs testing with modified gcc. The reason the ldil/addl sequence isn't supported is that it's hard to find the addl if the two instructions are separated. I'm pretty sure it's non trivial to improve LRA's spill handling. The testcase in the PR compiles fine with old reload. > This was probably back in the early gcc2 days, so unlikely you'd find a > discussion of this issue on the lists anywhere. Anyway, the point is, > be careful :-) Dave -- John David Anglin [email protected]
