> --- llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.8 Wed Dec 6 > 19:30:31 2006 > +++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp Tue Dec 12 > 17:36:14 2006 > @@ -20,9 +20,27 @@ > /// 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))); > + }
This code is not good, you shouldn't look at the type of the value. InsertCastOfTo is called in two places: LoopStrengthReduce.cpp:1124 (in which case it is a truncate, maybe a bitcast) and at :213. The call in 213 is in getCastedVersionOf, which is called at :256 (in which case it should be ptrtoint) and :271 (in which case it should be sext or bitcast). Please pass down the correct opcode from these callers. -Chris _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits