[llvm-commits] [llvm] r49210 - /llvm/trunk/include/llvm/Support/LLVMBuilder.h

Duncan Sands baldrick at free.fr
Fri Apr 4 01:28:17 PDT 2008


Author: baldrick
Date: Fri Apr  4 03:28:13 2008
New Revision: 49210

URL: http://llvm.org/viewvc/llvm-project?rev=49210&view=rev
Log:
If a value is cast to its own type, then the cast
is not needed.

Modified:
    llvm/trunk/include/llvm/Support/LLVMBuilder.h

Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=49210&r1=49209&r2=49210&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/LLVMBuilder.h Fri Apr  4 03:28:13 2008
@@ -615,20 +615,24 @@
                        const char *Name = "") {
     return CreateCast(Instruction::BitCast, V, DestTy, Name);
   }
-  
+
   Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy,
                     const char *Name = "") {
+    if (V->getType() == DestTy)
+      return V;
     if (Constant *VC = dyn_cast<Constant>(V))
       return ConstantExpr::getCast(Op, VC, DestTy);
     return LLVMBuilder::CreateCast(Op, V, DestTy, Name);
   }
   Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
                        const char *Name = "") {
+    if (V->getType() == DestTy)
+      return V;
     if (Constant *VC = dyn_cast<Constant>(V))
       return ConstantExpr::getIntegerCast(VC, DestTy, isSigned);
     return LLVMBuilder::CreateIntCast(V, DestTy, isSigned, Name);
   }
-  
+
   //===--------------------------------------------------------------------===//
   // Instruction creation methods: Compare Instructions
   //===--------------------------------------------------------------------===//





More information about the llvm-commits mailing list