[LLVMdev] ScalarEvolution Patch
Wojciech Matyjewicz
wmatyjewicz at fastmail.fm
Fri Feb 22 13:24:46 PST 2008
Hi,
> Is the following patch to ScalarEvolution correct? It seems that
> without it, the enclosing for loop could skip over SCEVAddRecExpr's in
> the Ops[] array.
The patch is correct, but doesn't seem to be necessary. Please note that
if a loop-invariant is found it is not only erased from the Ops[] array,
but also inserted into the LIOps[] one:
for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
std::vector<SCEVHandle> LIOps;
SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
LIOps.push_back(Ops[i]);
Ops.erase(Ops.begin()+i);
--i; --e;
}
and just after this code there is an dead-end 'if':
if (!LIOps.empty()) {
[...]
return getAddExpr(Ops);
}
[...]
}
that will never allow the outer 'for' loop to continue, if some loop
invariant was found.
But I admit it's a little bit obscure.
Wojtek
More information about the llvm-dev
mailing list