summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-13 08:06:42 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-13 08:06:42 +0000
commitdf1f19a8efde59a35b201242c9153d7409a390e5 (patch)
tree5472ab4df12f41ecddc6245b36112a982d9664cf /llvm/lib/Analysis/ScalarEvolutionExpander.cpp
parenta730cf80d79b92fd3bcd2ef2feda8c87860211a0 (diff)
downloadbcm5719-llvm-df1f19a8efde59a35b201242c9153d7409a390e5.tar.gz
bcm5719-llvm-df1f19a8efde59a35b201242c9153d7409a390e5.zip
Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller. Adjust the callers to pass the expected opcode. llvm-svn: 32535
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index db23a24d606..5e395db5e23 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -19,25 +19,8 @@ using namespace llvm;
/// InsertCastOfTo - Insert a cast of V to the specified type, doing what
/// we can to share the casts.
-Value *SCEVExpander::InsertCastOfTo(Value *V, const Type *Ty) {
- // Compute the Cast opcode to use
- Instruction::CastOps opcode = Instruction::BitCast;
- if (Ty->isIntegral()) {
- if (V->getType()->getTypeID() == Type::PointerTyID)
- opcode = Instruction::PtrToInt;
- else {
- unsigned SrcBits = V->getType()->getPrimitiveSizeInBits();
- unsigned DstBits = Ty->getPrimitiveSizeInBits();
- opcode = (SrcBits > DstBits ? Instruction::Trunc :
- (SrcBits == DstBits ? Instruction::BitCast :
- (V->getType()->isSigned() ? Instruction::SExt :
- Instruction::ZExt)));
- }
- } else if (Ty->isFloatingPoint())
- opcode = Instruction::UIToFP;
- else if (Ty->getTypeID() == Type::PointerTyID && V->getType()->isIntegral())
- opcode = Instruction::IntToPtr;
-
+Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V,
+ const Type *Ty) {
// FIXME: keep track of the cast instruction.
if (Constant *C = dyn_cast<Constant>(V))
return ConstantExpr::getCast(opcode, C, Ty);
OpenPOWER on IntegriCloud