From ddd1b7b801d8241dcc28c43792d0b73bac354632 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 20 Nov 2010 18:43:35 +0000 Subject: [PATCH] Simplify code. No change in functionality. llvm-svn: 119908 --- llvm/lib/Analysis/ScalarEvolution.cpp | 4 ++-- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 2 +- .../Transforms/Scalar/ScalarReplAggregates.cpp | 2 +- llvm/lib/Transforms/Utils/InlineFunction.cpp | 2 +- llvm/lib/VMCore/Constants.cpp | 16 ++++++---------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 141cc9fa76d9..84dca47ef8b5 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -5075,13 +5075,13 @@ bool ScalarEvolution::SimplifyICmpOperands(ICmpInst::Predicate &Pred, trivially_true: // Return 0 == 0. - LHS = RHS = getConstant(Type::getInt1Ty(getContext()), 0); + LHS = RHS = getConstant(ConstantInt::getFalse(getContext())); Pred = ICmpInst::ICMP_EQ; return true; trivially_false: // Return 0 != 0. - LHS = RHS = getConstant(Type::getInt1Ty(getContext()), 0); + LHS = RHS = getConstant(ConstantInt::getFalse(getContext())); Pred = ICmpInst::ICMP_NE; return true; } diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index c866659c6204..6f53c322ef5f 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -496,7 +496,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { // align ConstantInt::get(Type::getInt32Ty(Context), Alignment), // volatile - ConstantInt::get(Type::getInt1Ty(Context), 0), + ConstantInt::getFalse(Context), }; const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index a20d769ba3f1..3d676b2b2465 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1477,7 +1477,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *Inst, EltPtr, MI->getArgOperand(1), // Dest, Value, ConstantInt::get(MI->getArgOperand(2)->getType(), EltSize), // Size Zero, // Align - ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile + ConstantInt::getFalse(MI->getContext()) // isVolatile }; const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; Module *M = MI->getParent()->getParent()->getParent(); diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index f57fec7d4c7c..d60f9080502a 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -338,7 +338,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI) { Value *CallArgs[] = { DestCast, SrcCast, Size, ConstantInt::get(Type::getInt32Ty(Context), 1), - ConstantInt::get(Type::getInt1Ty(Context), 0) + ConstantInt::getFalse(Context) // isVolatile }; CallInst *TheMemCpy = CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 16eaca81048b..5bbf087e486d 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -265,20 +265,16 @@ ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V) ConstantInt* ConstantInt::getTrue(LLVMContext &Context) { LLVMContextImpl *pImpl = Context.pImpl; - if (pImpl->TheTrueVal) - return pImpl->TheTrueVal; - else - return (pImpl->TheTrueVal = - ConstantInt::get(IntegerType::get(Context, 1), 1)); + if (!pImpl->TheTrueVal) + pImpl->TheTrueVal = ConstantInt::get(Type::getInt1Ty(Context), 1); + return pImpl->TheTrueVal; } ConstantInt* ConstantInt::getFalse(LLVMContext &Context) { LLVMContextImpl *pImpl = Context.pImpl; - if (pImpl->TheFalseVal) - return pImpl->TheFalseVal; - else - return (pImpl->TheFalseVal = - ConstantInt::get(IntegerType::get(Context, 1), 0)); + if (!pImpl->TheFalseVal) + pImpl->TheFalseVal = ConstantInt::get(Type::getInt1Ty(Context), 0); + return pImpl->TheFalseVal; }