llvm.org GIT mirror llvm / b51a0d8
If a value is cast to its own type, then the cast is not needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49210 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 12 years ago
1 changed file(s) with 6 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
614614 const char *Name = "") {
615615 return CreateCast(Instruction::BitCast, V, DestTy, Name);
616616 }
617
617
618618 Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy,
619619 const char *Name = "") {
620 if (V->getType() == DestTy)
621 return V;
620622 if (Constant *VC = dyn_cast(V))
621623 return ConstantExpr::getCast(Op, VC, DestTy);
622624 return LLVMBuilder::CreateCast(Op, V, DestTy, Name);
623625 }
624626 Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
625627 const char *Name = "") {
628 if (V->getType() == DestTy)
629 return V;
626630 if (Constant *VC = dyn_cast(V))
627631 return ConstantExpr::getIntegerCast(VC, DestTy, isSigned);
628632 return LLVMBuilder::CreateIntCast(V, DestTy, isSigned, Name);
629633 }
630
634
631635 //===--------------------------------------------------------------------===//
632636 // Instruction creation methods: Compare Instructions
633637 //===--------------------------------------------------------------------===//