Am 07.02.25 um 17:12 schrieb Jeff Law:
On 2/3/25 2:09 AM, Richard Sandiford wrote:
Jeff Law <jeffreya...@gmail.com> writes:
So pulling on this thread leads me into the code that sets up
ALLOCNO_WMODE in create_insn_allocnos:

           if ((a = ira_curr_regno_allocno_map[regno]) == NULL)
             {
               a = ira_create_allocno (regno, false, ira_curr_loop_tree_node);
               if (outer != NULL && GET_CODE (outer) == SUBREG)
                 {
                   machine_mode wmode = GET_MODE (outer);
                   if (partial_subreg_p (ALLOCNO_WMODE (a), wmode))
                     ALLOCNO_WMODE (a) = wmode;
                 }
             }
Note how we only set ALLOCNO_MODE only at allocno creation, so it'll
work as intended if and only if the first reference is via a SUBREG.

Huh, yeah, I agree that that looks wrong.

ISTM the fix here is to always do the check and set ALLOCNO_WMODE.

[ Snipped discussion on a non-issue. ]


So ISTM that moving the code out of the "if (... == NULL)" should be
enough on its own.

And it all makes sense that you caught this.  You and another colleague
at ARM were trying to address this exact problem ~11 years ago ;-)

Heh, thought it sounded familiar :)

So attached is the updated patch that adjusts IRA to avoid this problem.

Georg-Johann, this may explain an issue you were running into as well where you got an invalid allocation.  I think yours was at the higher end of the register file, but the core issue is potentially the same (looking at the first use rather than all of them for paradoxical subregs).

You mean https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116389 ?

As far as I can tell that only occurred with reload but not with LRA.

Johann

I've had this in my tester about a week.  So it's been through the crosses as well as various native bootstraps, including but not limited to m68k, ppc, s390, hppa, sh4, etc.  And just for good measure I bootstrapped & regression tested it on x86_64 a few minutes ago.

Pushing to the trunk.

Jeff

Reply via email to