Skip to content

Commit

Permalink
[NFC][SCEV] getRelevantLoop(): deduplicate handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Jan 22, 2023
1 parent a81e070 commit c0081c1
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,32 +684,22 @@ const Loop *SCEVExpander::getRelevantLoop(const SCEV *S) {
case scTruncate:
case scZeroExtend:
case scSignExtend:
case scPtrToInt: {
const SCEVCastExpr *C = cast<SCEVCastExpr>(S);
const Loop *Result = getRelevantLoop(C->getOperand());
return RelevantLoops[C] = Result;
}
case scUDivExpr: {
const SCEVUDivExpr *D = cast<SCEVUDivExpr>(S);
const Loop *Result = PickMostRelevantLoop(
getRelevantLoop(D->getLHS()), getRelevantLoop(D->getRHS()), SE.DT);
return RelevantLoops[D] = Result;
}
case scPtrToInt:
case scAddExpr:
case scMulExpr:
case scUDivExpr:
case scAddRecExpr:
case scUMaxExpr:
case scSMaxExpr:
case scUMinExpr:
case scSMinExpr:
case scSequentialUMinExpr: {
const SCEVNAryExpr *N = cast<SCEVNAryExpr>(S);
const Loop *L = nullptr;
if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S))
L = AR->getLoop();
for (const SCEV *Op : N->operands())
for (const SCEV *Op : S->operands())
L = PickMostRelevantLoop(L, getRelevantLoop(Op), SE.DT);
return RelevantLoops[N] = L;
return RelevantLoops[S] = L;
}
case scUnknown: {
const SCEVUnknown *U = cast<SCEVUnknown>(S);
Expand Down

0 comments on commit c0081c1

Please sign in to comment.