summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-14 22:53:18 +0000
committerDan Gohman <gohman@apple.com>2010-05-14 22:53:18 +0000
commit88fb25356211587a91d7c42f9d31e0e2b6d369cb (patch)
tree0bcab7d32fd2a678499ca16d5882a2ba71629f09 /llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
parent089e9421d2b8dc6fc03b5004cb3c8690a73d0ebc (diff)
downloadbcm5719-llvm-88fb25356211587a91d7c42f9d31e0e2b6d369cb.tar.gz
bcm5719-llvm-88fb25356211587a91d7c42f9d31e0e2b6d369cb.zip
Fast ISel trivially coalesces away no-op casts, so check for this when
setting kill flags. llvm-svn: 103832
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FastISel.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 253ceca15eb..1996c192ec7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/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();
}
OpenPOWER on IntegriCloud