diff options
author | Joshua Cao <cao.joshua@yahoo.com> | 2023-04-08 15:55:21 -0700 |
---|---|---|
committer | Joshua Cao <cao.joshua@yahoo.com> | 2023-04-08 15:56:08 -0700 |
commit | 24170fb8cd2c9c000a0b51d72f5477cc12ab6971 (patch) | |
tree | abc789c3984c8f3cf0d66080f0e1e7c041573e67 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | f448d44663a5aab02eba650b486d31e00eab4599 (diff) | |
download | llvm-24170fb8cd2c9c000a0b51d72f5477cc12ab6971.zip llvm-24170fb8cd2c9c000a0b51d72f5477cc12ab6971.tar.gz llvm-24170fb8cd2c9c000a0b51d72f5477cc12ab6971.tar.bz2 |
[SCEV][NFC] Fix `Do not use 'else' after 'return'`
Follow LLVM coding standards and make clangd emit less warnings.
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index df872f6..a2f0aa4 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -739,9 +739,8 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV, assert(LHead != RHead && "Two loops share the same header?"); if (DT.dominates(LHead, RHead)) return 1; - else - assert(DT.dominates(RHead, LHead) && - "No dominance between recurrences used by one SCEV?"); + assert(DT.dominates(RHead, LHead) && + "No dominance between recurrences used by one SCEV?"); return -1; } @@ -1193,10 +1192,9 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, Type *Ty, if (numTruncs < 2) { if (isa<SCEVAddExpr>(Op)) return getAddExpr(Operands); - else if (isa<SCEVMulExpr>(Op)) + if (isa<SCEVMulExpr>(Op)) return getMulExpr(Operands); - else - llvm_unreachable("Unexpected SCEV type for Op."); + llvm_unreachable("Unexpected SCEV type for Op."); } // Although we checked in the beginning that ID is not in the cache, it is // possible that during recursion and different modification ID was inserted @@ -1863,8 +1861,7 @@ const SCEV *ScalarEvolution::getZeroExtendExprImpl(const SCEV *Op, Type *Ty, Operands.push_back(getZeroExtendExpr(Operand, Ty)); if (isa<SCEVUMinExpr>(MinMax)) return getUMinExpr(Operands); - else - return getUMaxExpr(Operands); + return getUMaxExpr(Operands); } // zext(umin_seq(x, y)) -> umin_seq(zext(x), zext(y)) @@ -2140,8 +2137,7 @@ const SCEV *ScalarEvolution::getSignExtendExprImpl(const SCEV *Op, Type *Ty, Operands.push_back(getSignExtendExpr(Operand, Ty)); if (isa<SCEVSMinExpr>(MinMax)) return getSMinExpr(Operands); - else - return getSMaxExpr(Operands); + return getSMaxExpr(Operands); } // The cast wasn't folded; create an explicit cast node. @@ -3834,15 +3830,18 @@ const SCEV *ScalarEvolution::getMinMaxExpr(SCEVTypes Kind, ++Idx; assert(Idx < Ops.size()); auto FoldOp = [&](const APInt &LHS, const APInt &RHS) { - if (Kind == scSMaxExpr) + switch (Kind) { + case scSMaxExpr: return APIntOps::smax(LHS, RHS); - else if (Kind == scSMinExpr) + case scSMinExpr: return APIntOps::smin(LHS, RHS); - else if (Kind == scUMaxExpr) + case scUMaxExpr: return APIntOps::umax(LHS, RHS); - else if (Kind == scUMinExpr) + case scUMinExpr: return APIntOps::umin(LHS, RHS); - llvm_unreachable("Unknown SCEV min/max opcode"); + default: + llvm_unreachable("Unknown SCEV min/max opcode"); + } }; while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { @@ -7021,7 +7020,7 @@ ConstantRange ScalarEvolution::getRangeForAffineNoSelfWrappingAR( if (isKnownPositive(Step) && isKnownPredicateViaConstantRanges(LEPred, Start, End)) return RangeBetween; - else if (isKnownNegative(Step) && + if (isKnownNegative(Step) && isKnownPredicateViaConstantRanges(GEPred, Start, End)) return RangeBetween; return ConstantRange::getFull(BitWidth); @@ -8942,9 +8941,8 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeExitLimitFromCondImpl( if (ExitIfTrue == !CI->getZExtValue()) // The backedge is always taken. return getCouldNotCompute(); - else - // The backedge is never taken. - return getZero(CI->getType()); + // The backedge is never taken. + return getZero(CI->getType()); } // If we're exiting based on the overflow flag of an x.with.overflow intrinsic @@ -10624,8 +10622,7 @@ bool ScalarEvolution::SimplifyICmpOperands(ICmpInst::Predicate &Pred, LHSC->getValue(), RHSC->getValue())->isNullValue()) return TrivialCase(false); - else - return TrivialCase(true); + return TrivialCase(true); } // Otherwise swap the operands to put the constant on the right. std::swap(LHS, RHS); @@ -10656,7 +10653,7 @@ bool ScalarEvolution::SimplifyICmpOperands(ICmpInst::Predicate &Pred, ConstantRange ExactCR = ConstantRange::makeExactICmpRegion(Pred, RA); if (ExactCR.isFullSet()) return TrivialCase(true); - else if (ExactCR.isEmptySet()) + if (ExactCR.isEmptySet()) return TrivialCase(false); APInt NewRHS; @@ -10901,7 +10898,7 @@ std::optional<bool> ScalarEvolution::evaluatePredicate(ICmpInst::Predicate Pred, const SCEV *RHS) { if (isKnownPredicate(Pred, LHS, RHS)) return true; - else if (isKnownPredicate(ICmpInst::getInversePredicate(Pred), LHS, RHS)) + if (isKnownPredicate(ICmpInst::getInversePredicate(Pred), LHS, RHS)) return false; return std::nullopt; } @@ -10923,7 +10920,7 @@ ScalarEvolution::evaluatePredicateAt(ICmpInst::Predicate Pred, const SCEV *LHS, if (isBasicBlockEntryGuardedByCond(CtxI->getParent(), Pred, LHS, RHS)) return true; - else if (isBasicBlockEntryGuardedByCond(CtxI->getParent(), + if (isBasicBlockEntryGuardedByCond(CtxI->getParent(), ICmpInst::getInversePredicate(Pred), LHS, RHS)) return false; @@ -10984,22 +10981,21 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS, if (!LHS->hasNoUnsignedWrap()) return std::nullopt; return IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing; - } else { - assert(ICmpInst::isSigned(Pred) && - "Relational predicate is either signed or unsigned!"); - if (!LHS->hasNoSignedWrap()) - return std::nullopt; + } + assert(ICmpInst::isSigned(Pred) && + "Relational predicate is either signed or unsigned!"); + if (!LHS->hasNoSignedWrap()) + return std::nullopt; - const SCEV *Step = LHS->getStepRecurrence(*this); + const SCEV *Step = LHS->getStepRecurrence(*this); - if (isKnownNonNegative(Step)) - return IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing; + if (isKnownNonNegative(Step)) + return IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing; - if (isKnownNonPositive(Step)) - return !IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing; + if (isKnownNonPositive(Step)) + return !IsGreater ? MonotonicallyIncreasing : MonotonicallyDecreasing; - return std::nullopt; - } + return std::nullopt; } std::optional<ScalarEvolution::LoopInvariantPredicate> |