[FastISel][AArch64] Fix an incorrect kill flag due to a bug in SelectTrunc.
authorJuergen Ributzka <juergen@apple.com>
Fri, 29 Aug 2014 17:58:16 +0000 (17:58 +0000)
committerJuergen Ributzka <juergen@apple.com>
Fri, 29 Aug 2014 17:58:16 +0000 (17:58 +0000)
commitd8835d09ecbb10919e5c8355aa1beb311d6d2ca7
treea7efad430d889c1b57ec317a4c13fe8cb3eb6c70
parent59758c433797035170ceef7008c0d5b117dc59c0
[FastISel][AArch64] Fix an incorrect kill flag due to a bug in SelectTrunc.

When we select a trunc instruction we don't emit any code if the type is already
i32 or smaller. This is because the instruction that uses the truncated value
will deal with it.

This behavior can incorrectly transfer a kill flag, which was meant for the
result of the truncate, onto the source register.

%2 = trunc i32 %1 to i16
... = ... %2                -> ... = ... vreg1 <kill>
... = ... %1                   ... = ... vreg1

This commit fixes this by emitting a COPY instruction, so that the result and
source register are distinct virtual registers.

This fixes rdar://problem/18178188.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216750 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64FastISel.cpp
test/CodeGen/AArch64/fast-isel-trunc.ll [new file with mode: 0644]