mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 02:33:53 +00:00
Revert "LSR: try not to blow up solving combinatorial problems brute force."
Some units tests crashed on a different platform. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6a51a7aea5
commit
81ba5060ea
@ -3006,63 +3006,42 @@ LSRInstance::CollectLoopInvariantFixupsAndFormulae() {
|
|||||||
|
|
||||||
/// CollectSubexprs - Split S into subexpressions which can be pulled out into
|
/// CollectSubexprs - Split S into subexpressions which can be pulled out into
|
||||||
/// separate registers. If C is non-null, multiply each subexpression by C.
|
/// separate registers. If C is non-null, multiply each subexpression by C.
|
||||||
static const SCEV *CollectSubexprs(const SCEV *S, const SCEVConstant *C,
|
static void CollectSubexprs(const SCEV *S, const SCEVConstant *C,
|
||||||
SmallVectorImpl<const SCEV *> &Ops,
|
SmallVectorImpl<const SCEV *> &Ops,
|
||||||
const Loop *L,
|
const Loop *L,
|
||||||
ScalarEvolution &SE,
|
ScalarEvolution &SE) {
|
||||||
unsigned Depth = 0) {
|
|
||||||
// Arbitrarily cap recursion to protect compile time.
|
|
||||||
if (Depth >= 3)
|
|
||||||
return S;
|
|
||||||
|
|
||||||
if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) {
|
if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) {
|
||||||
// Break out add operands.
|
// Break out add operands.
|
||||||
for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end();
|
for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end();
|
||||||
I != E; ++I) {
|
I != E; ++I)
|
||||||
const SCEV *Remainder = CollectSubexprs(*I, C, Ops, L, SE, Depth+1);
|
CollectSubexprs(*I, C, Ops, L, SE);
|
||||||
if (Remainder)
|
return;
|
||||||
Ops.push_back(C ? SE.getMulExpr(C, Remainder) : Remainder);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
} else if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) {
|
} else if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) {
|
||||||
// Split a non-zero base out of an addrec.
|
// Split a non-zero base out of an addrec.
|
||||||
if (AR->getStart()->isZero())
|
if (!AR->getStart()->isZero()) {
|
||||||
return S;
|
CollectSubexprs(SE.getAddRecExpr(SE.getConstant(AR->getType(), 0),
|
||||||
|
AR->getStepRecurrence(SE),
|
||||||
const SCEV *Remainder = CollectSubexprs(AR->getStart(),
|
AR->getLoop(),
|
||||||
C, Ops, L, SE, Depth+1);
|
//FIXME: AR->getNoWrapFlags(SCEV::FlagNW)
|
||||||
// Split the non-zero AddRec unless it is part of a nested recurrence that
|
SCEV::FlagAnyWrap),
|
||||||
// does not pertain to this loop.
|
C, Ops, L, SE);
|
||||||
if (AR->getLoop() == L || !isa<SCEVAddRecExpr>(Remainder)) {
|
CollectSubexprs(AR->getStart(), C, Ops, L, SE);
|
||||||
if (Remainder) {
|
return;
|
||||||
Ops.push_back(C ? SE.getMulExpr(C, Remainder) : Remainder);
|
|
||||||
Remainder = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Remainder != AR->getStart()) {
|
|
||||||
if (!Remainder)
|
|
||||||
Remainder = SE.getConstant(AR->getType(), 0);
|
|
||||||
return SE.getAddRecExpr(Remainder,
|
|
||||||
AR->getStepRecurrence(SE),
|
|
||||||
AR->getLoop(),
|
|
||||||
//FIXME: AR->getNoWrapFlags(SCEV::FlagNW)
|
|
||||||
SCEV::FlagAnyWrap);
|
|
||||||
}
|
}
|
||||||
} else if (const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(S)) {
|
} else if (const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(S)) {
|
||||||
// Break (C * (a + b + c)) into C*a + C*b + C*c.
|
// Break (C * (a + b + c)) into C*a + C*b + C*c.
|
||||||
if (Mul->getNumOperands() != 2)
|
if (Mul->getNumOperands() == 2)
|
||||||
return S;
|
if (const SCEVConstant *Op0 =
|
||||||
if (const SCEVConstant *Op0 =
|
dyn_cast<SCEVConstant>(Mul->getOperand(0))) {
|
||||||
dyn_cast<SCEVConstant>(Mul->getOperand(0))) {
|
CollectSubexprs(Mul->getOperand(1),
|
||||||
C = C ? cast<SCEVConstant>(SE.getMulExpr(C, Op0)) : Op0;
|
C ? cast<SCEVConstant>(SE.getMulExpr(C, Op0)) : Op0,
|
||||||
const SCEV *Remainder =
|
Ops, L, SE);
|
||||||
CollectSubexprs(Mul->getOperand(1), C, Ops, L, SE, Depth+1);
|
return;
|
||||||
if (Remainder)
|
}
|
||||||
Ops.push_back(SE.getMulExpr(C, Remainder));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return S;
|
|
||||||
|
// Otherwise use the value itself, optionally with a scale applied.
|
||||||
|
Ops.push_back(C ? SE.getMulExpr(C, S) : S);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GenerateReassociations - Split out subexpressions from adds and the bases of
|
/// GenerateReassociations - Split out subexpressions from adds and the bases of
|
||||||
@ -3077,9 +3056,7 @@ void LSRInstance::GenerateReassociations(LSRUse &LU, unsigned LUIdx,
|
|||||||
const SCEV *BaseReg = Base.BaseRegs[i];
|
const SCEV *BaseReg = Base.BaseRegs[i];
|
||||||
|
|
||||||
SmallVector<const SCEV *, 8> AddOps;
|
SmallVector<const SCEV *, 8> AddOps;
|
||||||
const SCEV *Remainder = CollectSubexprs(BaseReg, 0, AddOps, L, SE);
|
CollectSubexprs(BaseReg, 0, AddOps, L, SE);
|
||||||
if (Remainder)
|
|
||||||
AddOps.push_back(Remainder);
|
|
||||||
|
|
||||||
if (AddOps.size() == 1) continue;
|
if (AddOps.size() == 1) continue;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user