[PATCH] D31821: Remove redundant copy in recurrences

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 13:39:10 PDT 2017


On Fri, May 19, 2017 at 1:14 PM, Taewook Oh via Phabricator
<reviews at reviews.llvm.org> wrote:
> twoh added a comment.
>
> @wmi Thank you for your reply. I agree on you that we should consider tied operand group, and as @qcolombet mentioned in the previous comment, if tie operand information is already available before this pass, I'd like to discuss where would be the best place to implement this.
>
> I'm afraid I couldn't understand your second point. In the example there is a recurrence cycle of vreg0-->vreg13-->vreg3-->vreg10-->vreg0 as well, and what this patch does is commuting (vreg0, vreg1) and (vreg2, vreg10) to remove the copy. Did I miss something?

I don't think the cycle vreg0-->vreg13-->vreg3-->vreg10-->vreg0 is the
fundamental reason we have the redundent copy and need to commute the
operands. vreg3 and vreg10 won't be allocated to the same physical
register. Only vreg3 and vreg2 have to be allocated to the same
physical register because of the tied operand group. The fundamental
reason for the redundent copy is that "vreg0, vreg13, vreg3 and vreg2"
want the same physical register but vreg2 and vreg0 have interference
with each other.

Let's change the case a little:
vreg0 = vreg13
...
vreg10 = add vreg1, vreg0
vreg2 = load(vreg15)               // vreg2 is moved a little bit downwards.
vreg3 = add vreg2, vreg10
vreg13 = vreg3

Now You still have the cycle vreg0-->vreg13-->vreg3-->vreg10-->vreg0,
but you don't have to commute any operands to remove the redundent
copies now because vreg2 and vreg0 don't interfere with each other.

>
>
> https://reviews.llvm.org/D31821
>
>
>


More information about the llvm-commits mailing list