mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-25 04:55:50 +00:00
Reapply r112433, now that the real problem is addressed.
llvm-svn: 112666
This commit is contained in:
parent
a9b5b6bd36
commit
cadc463790
@ -1883,11 +1883,16 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
// there are multiple AddRec's with the same loop induction variable being
|
||||
// multiplied together. If so, we can fold them.
|
||||
for (unsigned OtherIdx = Idx+1;
|
||||
OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);++OtherIdx)
|
||||
if (OtherIdx != Idx) {
|
||||
const SCEVAddRecExpr *OtherAddRec = cast<SCEVAddRecExpr>(Ops[OtherIdx]);
|
||||
if (AddRecLoop == OtherAddRec->getLoop()) {
|
||||
// F * G --> {A,+,B} * {C,+,D} --> {A*C,+,F*D + G*B + B*D}
|
||||
OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
|
||||
++OtherIdx)
|
||||
if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) {
|
||||
// F * G, where F = {A,+,B}<L> and G = {C,+,D}<L> -->
|
||||
// {A*C,+,F*D + G*B + B*D}<L>
|
||||
for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
|
||||
++OtherIdx)
|
||||
if (const SCEVAddRecExpr *OtherAddRec =
|
||||
dyn_cast<SCEVAddRecExpr>(Ops[OtherIdx]))
|
||||
if (OtherAddRec->getLoop() == AddRecLoop) {
|
||||
const SCEVAddRecExpr *F = AddRec, *G = OtherAddRec;
|
||||
const SCEV *NewStart = getMulExpr(F->getStart(), G->getStart());
|
||||
const SCEV *B = F->getStepRecurrence(*this);
|
||||
@ -1898,12 +1903,10 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
|
||||
const SCEV *NewAddRec = getAddRecExpr(NewStart, NewStep,
|
||||
F->getLoop());
|
||||
if (Ops.size() == 2) return NewAddRec;
|
||||
|
||||
Ops.erase(Ops.begin()+Idx);
|
||||
Ops.erase(Ops.begin()+OtherIdx-1);
|
||||
Ops.push_back(NewAddRec);
|
||||
return getMulExpr(Ops);
|
||||
Ops[Idx] = AddRec = cast<SCEVAddRecExpr>(NewAddRec);
|
||||
Ops.erase(Ops.begin() + OtherIdx); --OtherIdx;
|
||||
}
|
||||
return getMulExpr(Ops);
|
||||
}
|
||||
|
||||
// Otherwise couldn't fold anything into this recurrence. Move onto the
|
||||
|
Loading…
Reference in New Issue
Block a user