mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-17 23:20:20 +00:00
[SCEV] Use range for loops; NFC
llvm-svn: 250633
This commit is contained in:
parent
fdfcb9c13b
commit
c8d2bcdfc3
@ -1132,8 +1132,8 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op,
|
|||||||
// If the input value is a chrec scev, truncate the chrec's operands.
|
// If the input value is a chrec scev, truncate the chrec's operands.
|
||||||
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) {
|
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) {
|
||||||
SmallVector<const SCEV *, 4> Operands;
|
SmallVector<const SCEV *, 4> Operands;
|
||||||
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
|
for (const SCEV *Op : AddRec->operands())
|
||||||
Operands.push_back(getTruncateExpr(AddRec->getOperand(i), Ty));
|
Operands.push_back(getTruncateExpr(Op, Ty));
|
||||||
return getAddRecExpr(Operands, AddRec->getLoop(), SCEV::FlagAnyWrap);
|
return getAddRecExpr(Operands, AddRec->getLoop(), SCEV::FlagAnyWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2638,10 +2638,9 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||||||
getZeroExtendExpr(Step, ExtTy),
|
getZeroExtendExpr(Step, ExtTy),
|
||||||
AR->getLoop(), SCEV::FlagAnyWrap)) {
|
AR->getLoop(), SCEV::FlagAnyWrap)) {
|
||||||
SmallVector<const SCEV *, 4> Operands;
|
SmallVector<const SCEV *, 4> Operands;
|
||||||
for (unsigned i = 0, e = AR->getNumOperands(); i != e; ++i)
|
for (const SCEV *Op : AR->operands())
|
||||||
Operands.push_back(getUDivExpr(AR->getOperand(i), RHS));
|
Operands.push_back(getUDivExpr(Op, RHS));
|
||||||
return getAddRecExpr(Operands, AR->getLoop(),
|
return getAddRecExpr(Operands, AR->getLoop(), SCEV::FlagNW);
|
||||||
SCEV::FlagNW);
|
|
||||||
}
|
}
|
||||||
/// Get a canonical UDivExpr for a recurrence.
|
/// Get a canonical UDivExpr for a recurrence.
|
||||||
/// {X,+,N}/C => {Y,+,N}/C where Y=X-(X%N). Safe when C%N=0.
|
/// {X,+,N}/C => {Y,+,N}/C where Y=X-(X%N). Safe when C%N=0.
|
||||||
@ -2662,8 +2661,8 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||||||
// (A*B)/C --> A*(B/C) if safe and B/C can be folded.
|
// (A*B)/C --> A*(B/C) if safe and B/C can be folded.
|
||||||
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(LHS)) {
|
if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(LHS)) {
|
||||||
SmallVector<const SCEV *, 4> Operands;
|
SmallVector<const SCEV *, 4> Operands;
|
||||||
for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i)
|
for (const SCEV *Op : M->operands())
|
||||||
Operands.push_back(getZeroExtendExpr(M->getOperand(i), ExtTy));
|
Operands.push_back(getZeroExtendExpr(Op, ExtTy));
|
||||||
if (getZeroExtendExpr(M, ExtTy) == getMulExpr(Operands))
|
if (getZeroExtendExpr(M, ExtTy) == getMulExpr(Operands))
|
||||||
// Find an operand that's safely divisible.
|
// Find an operand that's safely divisible.
|
||||||
for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = M->getNumOperands(); i != e; ++i) {
|
||||||
@ -2680,8 +2679,8 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||||||
// (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded.
|
// (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded.
|
||||||
if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(LHS)) {
|
if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(LHS)) {
|
||||||
SmallVector<const SCEV *, 4> Operands;
|
SmallVector<const SCEV *, 4> Operands;
|
||||||
for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i)
|
for (const SCEV *Op : A->operands())
|
||||||
Operands.push_back(getZeroExtendExpr(A->getOperand(i), ExtTy));
|
Operands.push_back(getZeroExtendExpr(Op, ExtTy));
|
||||||
if (getZeroExtendExpr(A, ExtTy) == getAddExpr(Operands)) {
|
if (getZeroExtendExpr(A, ExtTy) == getAddExpr(Operands)) {
|
||||||
Operands.clear();
|
Operands.clear();
|
||||||
for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i) {
|
||||||
@ -6066,8 +6065,7 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
|
|||||||
if (CanConstantFold(I)) {
|
if (CanConstantFold(I)) {
|
||||||
SmallVector<Constant *, 4> Operands;
|
SmallVector<Constant *, 4> Operands;
|
||||||
bool MadeImprovement = false;
|
bool MadeImprovement = false;
|
||||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
|
for (Value *Op : I->operands()) {
|
||||||
Value *Op = I->getOperand(i);
|
|
||||||
if (Constant *C = dyn_cast<Constant>(Op)) {
|
if (Constant *C = dyn_cast<Constant>(Op)) {
|
||||||
Operands.push_back(C);
|
Operands.push_back(C);
|
||||||
continue;
|
continue;
|
||||||
@ -8844,11 +8842,8 @@ ScalarEvolution::~ScalarEvolution() {
|
|||||||
|
|
||||||
// Free any extra memory created for ExitNotTakenInfo in the unlikely event
|
// Free any extra memory created for ExitNotTakenInfo in the unlikely event
|
||||||
// that a loop had multiple computable exits.
|
// that a loop had multiple computable exits.
|
||||||
for (DenseMap<const Loop*, BackedgeTakenInfo>::iterator I =
|
for (auto &BTCI : BackedgeTakenCounts)
|
||||||
BackedgeTakenCounts.begin(), E = BackedgeTakenCounts.end();
|
BTCI.second.clear();
|
||||||
I != E; ++I) {
|
|
||||||
I->second.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(PendingLoopPredicates.empty() && "isImpliedCond garbage");
|
assert(PendingLoopPredicates.empty() && "isImpliedCond garbage");
|
||||||
assert(!WalkingBEDominatingConds && "isLoopBackedgeGuardedByCond garbage!");
|
assert(!WalkingBEDominatingConds && "isLoopBackedgeGuardedByCond garbage!");
|
||||||
@ -8906,11 +8901,11 @@ void ScalarEvolution::print(raw_ostream &OS) const {
|
|||||||
OS << "Classifying expressions for: ";
|
OS << "Classifying expressions for: ";
|
||||||
F.printAsOperand(OS, /*PrintType=*/false);
|
F.printAsOperand(OS, /*PrintType=*/false);
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
|
for (Instruction &I : instructions(F))
|
||||||
if (isSCEVable(I->getType()) && !isa<CmpInst>(*I)) {
|
if (isSCEVable(I.getType()) && !isa<CmpInst>(I)) {
|
||||||
OS << *I << '\n';
|
OS << I << '\n';
|
||||||
OS << " --> ";
|
OS << " --> ";
|
||||||
const SCEV *SV = SE.getSCEV(&*I);
|
const SCEV *SV = SE.getSCEV(&I);
|
||||||
SV->print(OS);
|
SV->print(OS);
|
||||||
if (!isa<SCEVCouldNotCompute>(SV)) {
|
if (!isa<SCEVCouldNotCompute>(SV)) {
|
||||||
OS << " U: ";
|
OS << " U: ";
|
||||||
@ -8919,7 +8914,7 @@ void ScalarEvolution::print(raw_ostream &OS) const {
|
|||||||
SE.getSignedRange(SV).print(OS);
|
SE.getSignedRange(SV).print(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Loop *L = LI.getLoopFor((*I).getParent());
|
const Loop *L = LI.getLoopFor(I.getParent());
|
||||||
|
|
||||||
const SCEV *AtUse = SE.getSCEVAtScope(SV, L);
|
const SCEV *AtUse = SE.getSCEVAtScope(SV, L);
|
||||||
if (AtUse != SV) {
|
if (AtUse != SV) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user