From c9d41e7d27ffbae9cb041712c63c0e7a23acf5fe Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 26 Dec 2007 18:20:19 +0000 Subject: [PATCH] No need to do work that the folding builder does for us. llvm-svn: 45361 --- clang/CodeGen/CGExprScalar.cpp | 51 ++++++++++------------------------ 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/clang/CodeGen/CGExprScalar.cpp b/clang/CodeGen/CGExprScalar.cpp index 81a0cedf4e98..a4131507e386 100644 --- a/clang/CodeGen/CGExprScalar.cpp +++ b/clang/CodeGen/CGExprScalar.cpp @@ -368,50 +368,27 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, // Finally, we have the arithmetic types: real int/float. if (isa(Src->getType())) { bool InputSigned = SrcType->isSignedIntegerType(); - if (llvm::Constant *C = dyn_cast(Src)) { - if (isa(DstTy)) - return llvm::ConstantExpr::getIntegerCast(C, DstTy, InputSigned); - else if (InputSigned) - return llvm::ConstantExpr::getSIToFP(C, DstTy); - else - return llvm::ConstantExpr::getUIToFP(C, DstTy); - } else { - if (isa(DstTy)) - return Builder.CreateIntCast(Src, DstTy, InputSigned, "conv"); - else if (InputSigned) - return Builder.CreateSIToFP(Src, DstTy, "conv"); - else - return Builder.CreateUIToFP(Src, DstTy, "conv"); - } + if (isa(DstTy)) + return Builder.CreateIntCast(Src, DstTy, InputSigned, "conv"); + else if (InputSigned) + return Builder.CreateSIToFP(Src, DstTy, "conv"); + else + return Builder.CreateUIToFP(Src, DstTy, "conv"); } assert(Src->getType()->isFloatingPoint() && "Unknown real conversion"); if (isa(DstTy)) { - if (llvm::Constant *C = dyn_cast(Src)) { - if (DstType->isSignedIntegerType()) - return llvm::ConstantExpr::getFPToSI(C, DstTy); - else - return llvm::ConstantExpr::getFPToUI(C, DstTy); - } else { - if (DstType->isSignedIntegerType()) - return Builder.CreateFPToSI(Src, DstTy, "conv"); - else - return Builder.CreateFPToUI(Src, DstTy, "conv"); - } + if (DstType->isSignedIntegerType()) + return Builder.CreateFPToSI(Src, DstTy, "conv"); + else + return Builder.CreateFPToUI(Src, DstTy, "conv"); } assert(DstTy->isFloatingPoint() && "Unknown real conversion"); - if (llvm::Constant *C = dyn_cast(Src)) { - if (DstTy->getTypeID() < Src->getType()->getTypeID()) - return llvm::ConstantExpr::getFPTrunc(C, DstTy); - else - return llvm::ConstantExpr::getFPExtend(C, DstTy); - } else { - if (DstTy->getTypeID() < Src->getType()->getTypeID()) - return Builder.CreateFPTrunc(Src, DstTy, "conv"); - else - return Builder.CreateFPExt(Src, DstTy, "conv"); - } + if (DstTy->getTypeID() < Src->getType()->getTypeID()) + return Builder.CreateFPTrunc(Src, DstTy, "conv"); + else + return Builder.CreateFPExt(Src, DstTy, "conv"); } /// EmitComplexToScalarConversion - Emit a conversion from the specified