OSDN Git Service

MachineCopyPropagation: Remove the copies instead of using KILL instructions.
authorMatthias Braun <matze@braunis.de>
Fri, 29 May 2015 18:19:25 +0000 (18:19 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 29 May 2015 18:19:25 +0000 (18:19 +0000)
commit3bd732d1eee711139519f8a938290818e5b18867
tree36693ff0e010c10769dcfd43fd8b734fada94c24
parent2368d54c079972ab59253b0fa8a26efcad0811b1
MachineCopyPropagation: Remove the copies instead of using KILL instructions.

For some history here see the commit messages of r199797 and r169060.

The original intent was to fix cases like:

%EAX<def> = COPY %ECX<kill>, %RAX<imp-def>
%RCX<def> = COPY %RAX<kill>

where simply removing the copies would have RCX undefined as in terms of
machine operands only the ECX part of it is defined. The machine
verifier would complain about this so 169060 changed such COPY
instructions into KILL instructions so some super-register imp-defs
would be preserved. In r199797 it was finally decided to always do this
regardless of super-register defs.

But this is wrong, consider:
R1 = COPY R0
...
R0 = COPY R1
getting changed to:
R1 = KILL R0
...
R0 = KILL R1

It now looks like R0 dies at the first KILL and won't be alive until the
second KILL, while in reality R0 is alive and must not change in this
part of the program.

As this only happens after register allocation there is not much code
still performing liveness queries so the issue was not noticed.  In fact
I didn't manage to create a testcase for this, without unrelated changes
I am working on at the moment.

The fix is simple: As of r223896 the MachineVerifier allows reads from
partially defined registers, so the whole transforming COPY->KILL thing
is not necessary anymore. This patch also changes a similar (but more
benign case as the def and src are the same register) case in the
VirtRegRewriter.

Differential Revision: http://reviews.llvm.org/D10117

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238588 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineCopyPropagation.cpp
lib/CodeGen/VirtRegMap.cpp
test/CodeGen/X86/avx512-vec-cmp.ll
test/CodeGen/X86/critical-anti-dep-breaker.ll
test/CodeGen/X86/vec_fp_to_int.ll
test/CodeGen/X86/vector-shuffle-256-v4.ll
test/CodeGen/X86/vector-zext.ll