[AArch64] Extend AArch64RedundantCopyElimination to do simple copy propagation.

Description

[AArch64] Extend AArch64RedundantCopyElimination to do simple copy propagation.

Summary:
Extend AArch64RedundantCopyElimination to catch cases where the register
that is known to be zero is COPY'd in the predecessor block. Before
this change, this pass would catch cases like:

    CBZW %W0, <BB#1>
BB#1:
    %W0 = COPY %WZR // removed

After this change, cases like the one below are also caught:

    %W0 = COPY %W1
    CBZW %W1, <BB#1>
BB#1:
    %W0 = COPY %WZR // removed

This change results in a 4% increase in static copies removed by this
pass when compiling the llvm test-suite. It also fixes regressions
caused by doing post-RA copy propagation (a separate change to be put up
for review shortly).

Reviewers: junbuml, mcrosier, t.p.northover, qcolombet, MatzeB

Subscribers: aemerson, rengolin, llvm-commits

Differential Revision: https://reviews.llvm.org/D30113

mcrosier added inline comments.
/llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
170

Is this break statement unintentional, Geoff? We're exiting the do-while, without checking the while condition.

gberry added inline comments.Feb 28 2017, 11:00 AM
/llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
170

No, it is intentional (though admittedly a bit opaque). We break out of the loop once we find the first conditional branch that implies the condition value in the current block. The while condition gets checked when we take the 'continue' path from line 129.