Skip to content

Commit

Permalink
[NFC][SCEV] getLoopDisposition(): deduplicate handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Jan 22, 2023
1 parent 906e995 commit cc016e6
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Expand Up @@ -13642,11 +13642,6 @@ ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
switch (S->getSCEVType()) {
case scConstant:
return LoopInvariant;
case scPtrToInt:
case scTruncate:
case scZeroExtend:
case scSignExtend:
return getLoopDisposition(cast<SCEVCastExpr>(S)->getOperand(), L);
case scAddRecExpr: {
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(S);

Expand Down Expand Up @@ -13677,15 +13672,20 @@ ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
// Otherwise it's loop-invariant.
return LoopInvariant;
}
case scTruncate:
case scZeroExtend:
case scSignExtend:
case scPtrToInt:
case scAddExpr:
case scMulExpr:
case scUDivExpr:
case scUMaxExpr:
case scSMaxExpr:
case scUMinExpr:
case scSMinExpr:
case scSequentialUMinExpr: {
bool HasVarying = false;
for (const auto *Op : cast<SCEVNAryExpr>(S)->operands()) {
for (const auto *Op : S->operands()) {
LoopDisposition D = getLoopDisposition(Op, L);
if (D == LoopVariant)
return LoopVariant;
Expand All @@ -13694,17 +13694,6 @@ ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
}
return HasVarying ? LoopComputable : LoopInvariant;
}
case scUDivExpr: {
const SCEVUDivExpr *UDiv = cast<SCEVUDivExpr>(S);
LoopDisposition LD = getLoopDisposition(UDiv->getLHS(), L);
if (LD == LoopVariant)
return LoopVariant;
LoopDisposition RD = getLoopDisposition(UDiv->getRHS(), L);
if (RD == LoopVariant)
return LoopVariant;
return (LD == LoopInvariant && RD == LoopInvariant) ?
LoopInvariant : LoopComputable;
}
case scUnknown:
// All non-instruction values are loop invariant. All instructions are loop
// invariant if they are not contained in the specified loop.
Expand Down

0 comments on commit cc016e6

Please sign in to comment.