From 3ba68b9eef2851dae8a9d1b18928c6fa2e3c5f87 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 13 Dec 2006 08:06:42 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32535 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolutionExpander.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp') diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index db23a24d60..5e395db5e2 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/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(V)) return ConstantExpr::getCast(opcode, C, Ty); -- cgit v1.2.3