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;
}
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
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))
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.
++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])) {
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);
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
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);
ConstantRange ExactCR = ConstantRange::makeExactICmpRegion(Pred, RA);
if (ExactCR.isFullSet())
return TrivialCase(true);
- else if (ExactCR.isEmptySet())
+ if (ExactCR.isEmptySet())
return TrivialCase(false);
APInt NewRHS;
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;
}
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;
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>