summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-04-04 08:28:13 +0000
committerDuncan Sands <baldrick@free.fr>2008-04-04 08:28:13 +0000
commit4cbca05d4e0543f835aeff201c60348387b7e88e (patch)
treec56adf35c0f1408ec2c640929cfea9bd2aca7ce0
parent602647aa70a6c02041d8aa8778ab05e46f0735c9 (diff)
downloadbcm5719-llvm-4cbca05d4e0543f835aeff201c60348387b7e88e.tar.gz
bcm5719-llvm-4cbca05d4e0543f835aeff201c60348387b7e88e.zip
If a value is cast to its own type, then the cast
is not needed. llvm-svn: 49210
-rw-r--r--llvm/include/llvm/Support/LLVMBuilder.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/LLVMBuilder.h b/llvm/include/llvm/Support/LLVMBuilder.h
index ef1817d3c16..2a7fc635d72 100644
--- a/llvm/include/llvm/Support/LLVMBuilder.h
+++ b/llvm/include/llvm/Support/LLVMBuilder.h
@@ -615,20 +615,24 @@ public:
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
//===--------------------------------------------------------------------===//
OpenPOWER on IntegriCloud