public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/2][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
@ 2018-09-26 21:14 Peter Bergner
  2018-09-26 21:16 ` [PATCH 1/2][IRA,LRA] " Peter Bergner
                   ` (2 more replies)
  0 siblings, 3 replies; 66+ messages in thread
From: Peter Bergner @ 2018-09-26 21:14 UTC (permalink / raw)
  To: GCC Patches; +Cc: Vladimir N Makarov, Jeff Law

PR86939 shows a problem where IRA (and LRA) adds an unneeded conflict between
a pseudo reg and a hard reg leading to an unnecessary copy.  The definition
of conflict that most register allocators use is that two live ranges conflict
if one is "live" at the definition of the other and they have different
values (here "live" means live and available).  In computing conflicts,
IRA/LRA do not try and represent the "...and they have different values"
which leads to the unneeded conflict.  They also add conflicts when they
handle insn operand uses, rather than at operand definitions that the
definition above implies and that other allocators I know about do.

The following 2 patches fixes (some) of the problems mentioned above
and is enough to fix the performance problem reported in the PR.
Firstly, PATCH 1 changes IRA and LRA to compute conflicts when handling
definitions, rather than at uses.  This change is required by the second
patch, since we cannot handle reg to reg copies specially (ie, skip the
addition of a conflict) if we've already made them conflict because we
noticed they're live simultaneously.  Technically, this should only
make a difference in the conflicts computed for two live ranges that
are both undefined.  Not really likely.  I also took it upon myself to
rename the *_born functions, since the live ranges are not born at the
point we call them.  They are actually deaths/last uses and we need to
add them to the "live" sets (we traverse the basic blocks in reverse).
Therefore, I changes the suffix from _born to _live.

PATCH 2 adds the special handling of pseudo to/from hard reg copies.
Specifically, we ignore the source reg of the copy when adding conflicts
for the reg that is being defined in the copy insn.  A few things I'd
like to point out.  Normally, in the other allocators I'm familiar with,
we handle conflicts for copies by removing the source reg from the "live"
set, even if it doesn't die in the copy.  Then when we process the
copies definitions, we add conflicts with everything that is live.
Since we've removed the source reg, then we've successfully not added a
conflict here.  Then we process the copies uses which will automatically
add the source reg back to the live set.  I tried that here too, but
given allocno ranges computation, I couldn't do that here.  I decided
just to create a global var that I can test for when adding conflicts.
Also, this patch does not handle pseudo to pseudo copies, since their
conflicts are computed by checking their allocno ranges for overlap
and I could not determine how to recognize and handle copies during
that process.  If someone has ideas, please let me know.  Finally, I
have explicitly disallowed special handling of copies of register pairs,
since that is difficult to get right.  I tried several solutions before
finally just giving up on them.  That could be a future work item along
with pseudo to pseudo handling if people want.

I'll note that I have bootstrapped and regtested PATCH 1 on both
powerpc64le-linux and x86_64-linux with not regressions.  I have
also bootstrapped and regtested PATCH 1 + PATCH 2 on the same two
platforms with no regressions.

Vlad, Jeff or anyone else, any comments on the approach used here
to fix PR86939?

If the patches are "ok" as is, I'd like to commit PATCH 1 first and
let it bake on trunk for a little while before committing PATCH 2.

Peter


^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2018-11-08 19:01 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 21:14 [PATCH 0/2][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register Peter Bergner
2018-09-26 21:16 ` [PATCH 1/2][IRA,LRA] " Peter Bergner
2018-09-26 21:36 ` [PATCH 2/2][IRA,LRA] " Peter Bergner
2018-09-28 21:45 ` [PATCH 0/2][IRA,LRA] " Vladimir Makarov
2018-09-30 20:28   ` Peter Bergner
2018-10-01  0:57     ` H.J. Lu
2018-10-01  1:18       ` Peter Bergner
2018-10-01 12:46         ` H.J. Lu
2018-10-01 12:51           ` H.J. Lu
2018-10-01 13:16             ` H.J. Lu
2018-10-01 14:05               ` Peter Bergner
2018-10-02  4:08             ` Peter Bergner
2018-10-02 14:50               ` Jeff Law
2018-10-02 15:07               ` Peter Bergner
2018-10-02 15:37                 ` H.J. Lu
2018-10-02 15:55                   ` Peter Bergner
2018-10-02 17:14                     ` H.J. Lu
2018-10-02 21:53                 ` Peter Bergner
2018-10-02 22:28                   ` H.J. Lu
2018-10-03  0:35                     ` Peter Bergner
2018-10-03  2:23                       ` H.J. Lu
2018-10-03  2:46                         ` Peter Bergner
2018-10-03 14:43                 ` [PATCH 2/2 v3][IRA,LRA] " Peter Bergner
2018-10-04 22:18                   ` Vladimir Makarov
2018-10-05 16:50                     ` Peter Bergner
2018-10-05 18:54                       ` Vladimir Makarov
2018-10-05 20:10                         ` Peter Bergner
2018-10-05 22:56                           ` Vladimir Makarov
2018-10-06  6:40                             ` Peter Bergner
2018-10-08  9:37                               ` Christophe Lyon
2018-10-08 14:21                                 ` Peter Bergner
2018-10-08 14:46                                   ` Christophe Lyon
2018-10-08 15:04                                     ` Jeff Law
2018-10-11  2:57                                       ` Peter Bergner
2018-10-11 18:26                                         ` Peter Bergner
2018-10-11 20:31                                           ` Peter Bergner
2018-10-11 20:46                                             ` Jeff Law
2018-10-11 21:09                                               ` Peter Bergner
2018-10-11 21:36                                                 ` Jeff Law
2018-10-12  9:50                                                 ` Eric Botcazou
2018-10-11 21:05                                             ` Vladimir Makarov
2018-10-12 16:57                                               ` Peter Bergner
2018-10-12 17:56                                                 ` Jeff Law
2018-10-12  4:44                                             ` Jeff Law
2018-10-16  2:50                                               ` Peter Bergner
2018-11-01 18:50                                                 ` Renlin Li
2018-11-01 20:35                                                   ` Segher Boessenkool
2018-11-01 22:08                                                   ` Peter Bergner
2018-11-02 10:05                                                     ` Renlin Li
2018-11-05 19:20                                                     ` Jeff Law
2018-11-05 19:36                                                       ` Peter Bergner
2018-11-05 19:41                                                         ` Jeff Law
2018-11-06 10:52                                                           ` Renlin Li
2018-11-06 10:57                                                             ` Ramana Radhakrishnan
2018-11-06 12:23                                                               ` Renlin Li
2018-11-06 18:46                                                                 ` Peter Bergner
2018-11-06 18:58                                                             ` Jeff Law
2018-11-08 10:57                                                               ` Renlin Li
2018-11-08 11:49                                                                 ` Richard Biener
2018-11-08 14:29                                                                   ` Peter Bergner
2018-11-08 19:01                                                                     ` Peter Bergner
2018-11-08 12:35                                                                 ` Peter Bergner
2018-11-08 13:42                                                                   ` Renlin Li
2018-11-08 15:21                                                                 ` Peter Bergner
2018-11-08 16:20                                                                   ` Renlin Li
2018-11-08 17:52                                                                     ` Peter Bergner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).