[PATCH] D38128: Handle COPYs of physregs better (regalloc hints)

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 03:24:02 PDT 2017


jonpa added a comment.

In https://reviews.llvm.org/D38128#904861, @uweigand wrote:

> In https://reviews.llvm.org/D38128#904781, @jonpa wrote:
>
> > In https://reviews.llvm.org/D38128#904581, @efriedma wrote:
> >
> > > > Not sure if it is clear that coalescing with %R8 is generally better than %R0.
> > >
> > > What do you mean, it isn't clear?  Is the performance problem not clear?  Or do you mean you're not sure how to detect this situation when you're sorting the hints?
> >
> >
> > I guess given your initial wording ("not great"), I was not sure if this is general and serious enough so that we really want to add an additional heuristic like "COPY to compare" on top of the sorting by weight. I suppose then there should be a flag like HasCompareUser which is then the tie-breaker when the weight is the same, or?
>
>
> I don't believe there's anything special about compare here, this applies the same to any other use.  In general, if you have something like "COPY dest, src" followed by "use dest", it is nearly always better to replace the second instruction by "use src" if this is possible (i.e. if src is still live and unchanged at that point).  This is simply because on most processor architectures "COPY dest, src / use src" can execute in parallel, while "COPY dest, src / use dest" must execute sequentially.


That makes sense.

Would any of these be an improvement worth trying, then?

(1) If the source phys-reg is contained in the regclass of an immediately following instruction using the vreg, then increase the priority of the hint of that phys-reg.
(2) A simpler alternative would be to simply prefer phys-reg sources more than phys-reg dest-regs (if weight is equal). That would catch all the cases of (1).


https://reviews.llvm.org/D38128





More information about the llvm-commits mailing list