From 981f1796e0c9779bcba0ccdede6c47b75bb96f70 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 5 Nov 2015 21:07:12 +0000 Subject: [PATCH] Refactor: Simplify boolean conditional return statements in llvm/lib/Analysis Patch by Richard Thomson! Differential revision: http://reviews.llvm.org/D9967 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252209 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicAliasAnalysis.cpp | 5 +---- lib/Analysis/CaptureTracking.cpp | 5 +---- lib/Analysis/CostModel.cpp | 5 +---- lib/Analysis/ScalarEvolution.cpp | 9 +++------ 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 1f7e82d3158..e3c336465a5 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -627,10 +627,7 @@ ModRefInfo BasicAAResult::getArgModRefInfo(ImmutableCallSite CS, static bool isAssumeIntrinsic(ImmutableCallSite CS) { const IntrinsicInst *II = dyn_cast(CS.getInstruction()); - if (II && II->getIntrinsicID() == Intrinsic::assume) - return true; - - return false; + return II && II->getIntrinsicID() == Intrinsic::assume; } #ifndef NDEBUG diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp index 230a380c4bf..c717a8ee2e6 100644 --- a/lib/Analysis/CaptureTracking.cpp +++ b/lib/Analysis/CaptureTracking.cpp @@ -102,10 +102,7 @@ namespace { SmallVector Worklist; Worklist.append(succ_begin(BB), succ_end(BB)); - if (!isPotentiallyReachableFromMany(Worklist, BB, DT)) - return true; - - return false; + return !isPotentiallyReachableFromMany(Worklist, BB, DT); } // If the value is defined in the same basic block as use and BeforeHere, diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp index 604cc2af746..b11f64d4bf0 100644 --- a/lib/Analysis/CostModel.cpp +++ b/lib/Analysis/CostModel.cpp @@ -152,10 +152,7 @@ static bool matchPairwiseShuffleMask(ShuffleVectorInst *SI, bool IsLeft, Mask[i] = val; SmallVector ActualMask = SI->getShuffleMask(); - if (Mask != ActualMask) - return false; - - return true; + return Mask == ActualMask; } static bool matchPairwiseReductionAtLevel(const BinaryOperator *BinOp, diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 53e63d70a3e..0d4a62c9d80 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -7419,12 +7419,9 @@ bool ScalarEvolution::isKnownPredicateViaSplitting(ICmpInst::Predicate Pred, // expensive; and using isKnownNonNegative(RHS) is sufficient for most of the // interesting cases seen in practice. We can consider "upgrading" L >= 0 to // use isKnownPredicate later if needed. - if (isKnownNonNegative(RHS) && - isKnownPredicate(CmpInst::ICMP_SGE, LHS, getZero(LHS->getType())) && - isKnownPredicate(CmpInst::ICMP_SLT, LHS, RHS)) - return true; - - return false; + return isKnownNonNegative(RHS) && + isKnownPredicate(CmpInst::ICMP_SGE, LHS, getZero(LHS->getType())) && + isKnownPredicate(CmpInst::ICMP_SLT, LHS, RHS); } /// isLoopBackedgeGuardedByCond - Test whether the backedge of the loop is -- 2.34.1