diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-05-09 00:51:03 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-05-09 00:51:03 +0000 |
commit | d54fb8990171cf37f78ee64b5a94a1faae71b72a (patch) | |
tree | ad4d974244b87a1a9ddfec00a2555bc08c418a0b /llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | |
parent | dc2711446e877d0baea32f2663bb9b4602358c0e (diff) | |
download | bcm5719-llvm-d54fb8990171cf37f78ee64b5a94a1faae71b72a.tar.gz bcm5719-llvm-d54fb8990171cf37f78ee64b5a94a1faae71b72a.zip |
[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.
llvm-svn: 236922
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 13f0cb3900f..0351c33c28e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1684,10 +1684,13 @@ unsigned FastISel::fastEmit_ri_(MVT VT, unsigned Opcode, unsigned Op0, MaterialReg = getRegForValue(ConstantInt::get(ITy, Imm)); if (!MaterialReg) return 0; - // If this constant was already materialized, then we don't want to kill it. - // In this case we will have a use. - if (!MRI.use_empty(MaterialReg)) - IsImmKill = false; + // FIXME: If the materialized register here has no uses yet then this + // will be the first use and we should be able to mark it as killed. + // However, the local value area for materialising constant expressions + // grows down, not up, which means that any constant expressions we generate + // later which also use 'Imm' could be after this instruction and therefore + // after this kill. + IsImmKill = false; } return fastEmit_rr(VT, VT, Opcode, Op0, Op0IsKill, MaterialReg, IsImmKill); } |