From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17036 invoked by alias); 10 Mar 2015 19:21:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 16972 invoked by uid 48); 10 Mar 2015 19:21:43 -0000 From: "vmakarov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/64895] RA picks the wrong register for -fipa-ra Date: Tue, 10 Mar 2015 19:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: vmakarov at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01160.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64895 Vladimir Makarov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vmakarov at gcc dot gnu.org --- Comment #7 from Vladimir Makarov --- (In reply to vries from comment #6) > From PR64342 comment 7: > > Register allocation seems to progress similarly, up until this message in > reload, which seems to be directly related to the r216154 patch: > ... > Spill r86 after risky transformations > Reassigning non-reload pseudos > Assign 3 to r86 (freq=3000) > ... > > I've looked a bit in more detail at this message. > > fipa-ra manages to allocate hardreg 1 (dx) to the call-crossing liverange as > before. But setup_live_pseudos_and_spill_after_risky_transforms looks at the > conflict regs, and finds that lra_reg_info[regno].conflict_hard_regs > contains dx. Hence, it spills the liverange into an available reg, which > happens to be hardreg 3 (bx). > > So, the risky transformations and fipa-ra have in common that they allocate > registers from the conflict_hard_regs set. In the case of -fipa-ra, we don't > want setup_live_pseudos_and_spill_after_risky_transforms to undo the > -fipa-ra allocation, but currently there's no way to distinguish between the > two. > Right. Introduction of pic pseudo and possible rematerializations of memory references with the pic pseudo made checking the new conflict first necessary. Before this it was not a problem as pic hard reg was used only for pic addressing. > Using this patch, we make sure the conflict registers don't include dx for > this testcase, and the test-cases passes again: > ... > diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c > index 9dfffb6..0231057 100644 > --- a/gcc/lra-lives.c > +++ b/gcc/lra-lives.c > @@ -636,8 +636,11 @@ check_pseudos_live_through_calls (int regno) > if (! sparseset_bit_p (pseudos_live_through_calls, regno)) > return; > sparseset_clear_bit (pseudos_live_through_calls, regno); > + > IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs, > - call_used_reg_set); > + !hard_reg_set_empty_p > (lra_reg_info[regno].actual_call_used_reg_set) > + ? lra_reg_info[regno].actual_call_used_reg_set > + : call_used_reg_set); > > for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++) > if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno))) > ... The patch looks ok to me. Tom, could you prepare the patch (check it mostly for x86-64 bootstrap and testsuite) and commit it to the trunk. I approve it.