diff options
| author | Dan Gohman <gohman@apple.com> | 2010-05-14 22:53:18 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-05-14 22:53:18 +0000 |
| commit | 170e16745833e36e689b40a1892eeca6f2e3b4aa (patch) | |
| tree | 640bdcc7ecaff593205cea2e6f8874c25b0ea71e /lib/CodeGen/SelectionDAG | |
| parent | 2bc9006bd8d16c429530fb6f7f8b983807f635a2 (diff) | |
| download | external_llvm-170e16745833e36e689b40a1892eeca6f2e3b4aa.zip external_llvm-170e16745833e36e689b40a1892eeca6f2e3b4aa.tar.gz external_llvm-170e16745833e36e689b40a1892eeca6f2e3b4aa.tar.bz2 | |
Fast ISel trivially coalesces away no-op casts, so check for this when
setting kill flags.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103832 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
| -rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 253ceca..1996c19 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -57,11 +57,23 @@ using namespace llvm; bool FastISel::hasTrivialKill(const Value *V) const { - // Don't consider constants or arguments to have trivial kills. Only - // instructions with a single use in the same basic block. + // Don't consider constants or arguments to have trivial kills. const Instruction *I = dyn_cast<Instruction>(V); - return I && - I->hasOneUse() && + if (!I) + return false; + + // No-op casts are trivially coalesced by fast-isel. + if (const CastInst *Cast = dyn_cast<CastInst>(I)) + if (Cast->isNoopCast(TD.getIntPtrType(Cast->getContext())) && + !hasTrivialKill(Cast->getOperand(0))) + return false; + + // Only instructions with a single use in the same basic block are considered + // to have trivial kills. + return I->hasOneUse() && + !(I->getOpcode() == Instruction::BitCast || + I->getOpcode() == Instruction::PtrToInt || + I->getOpcode() == Instruction::IntToPtr) && cast<Instruction>(I->use_begin())->getParent() == I->getParent(); } |
