[llvm-commits] [llvm] r103832 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Dan Gohman
gohman at apple.com
Fri May 14 15:53:18 PDT 2010
Author: djg
Date: Fri May 14 17:53:18 2010
New Revision: 103832
URL: http://llvm.org/viewvc/llvm-project?rev=103832&view=rev
Log:
Fast ISel trivially coalesces away no-op casts, so check for this when
setting kill flags.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=103832&r1=103831&r2=103832&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri May 14 17:53:18 2010
@@ -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();
}
More information about the llvm-commits
mailing list