OSDN Git Service

[Fast-ISel] Don't mark the first use of a remat constant as killed.
authorPete Cooper <peter_cooper@apple.com>
Sat, 9 May 2015 00:51:03 +0000 (00:51 +0000)
committerPete Cooper <peter_cooper@apple.com>
Sat, 9 May 2015 00:51:03 +0000 (00:51 +0000)
commitf5b930b2e220473a6a4c4ba4d6f9f5fca70983e5
tree92b2351e4e72cc50ea9476a273603bd315f7dc3f
parent68e53f68e69342bc864896a073663fe826fe8101
[Fast-ISel] Don't mark the first use of a remat constant as killed.

When emitting something like 'add x, 1000' if we remat the 1000 then we should be able to
mark the vreg containing 1000 as killed.  Given that we go bottom up in fast-isel, a later
use of 1000 will be higher up in the BB and won't kill it, or be impacted by the lower kill.

However, rematerialised constant expressions aren't generated bottom up.  The local value save area
grows downwards.  This means that if you remat 2 constant expressions which both use 1000 then the
first will kill it, then the second, which is *lower* in the BB will read a killed register.

This is the case in the attached test where the 2 GEPs both need to generate 'add x, 6680' for the constant offset.

Note that this commit only makes kill flag generation conservative.  There's nothing else obviously wrong with
the local value save area growing downwards, and in fact it needs to for handling arbitrarily complex constant expressions.

However, it would be nice if there was a solution which would let us generate more accurate kill flags, or just kill flags completely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236922 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/FastISel.cpp
test/CodeGen/ARM/fast-isel-remat-same-constant.ll [new file with mode: 0644]