[llvm-commits] [llvm] r60374 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/2008-12-01-loop-iv-used-outside-loop.ll
Chris Lattner
clattner at apple.com
Mon Dec 1 20:56:08 PST 2008
On Dec 1, 2008, at 2:00 PM, Dale Johannesen wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=60374&view=rev
> Log:
> Consider only references to an IV within the loop when
> figuring out the base of the IV. This produces better
> code in the example. (Addresses use (IV) instead of
> (BASE,IV) - a significant improvement on low-register
> machines like x86).
Dale, this is an outstanding patch, thank you for tackling this! For
anyone following on the sidelines, this helps fix a performance
problem when compiling an inner loop of the GCC lexer.
One question:
>
> // Otherwise, remove all of the CSE's we found from each of the
> base values.
> for (unsigned i = 0; i != NumUses; ++i) {
> + // For this purpose, consider only uses that are inside the loop.
> + if (!L->contains(Uses[i].Inst->getParent()))
> + continue;
> +
>
> @@ -1450,6 +1464,12 @@
>
> + // If this reference is not in the loop and we have a Common
> base,
> + // that has been added into the induction variable and must be
> + // subtracted off here.
> + if (HaveCommonExprs && !L->contains(User.Inst->getParent()))
> + RewriteExpr = SE->getMinusSCEV(RewriteExpr, CommonExprs);
> +
These two hunks add a very subtle (and undocumented/commented) issue:
users outside the loop are missing common exprs from their base.
Would it be possible to change the first hunk to something like:
if (!L->contains(Uses[i].Inst->getParent())) {
Uses[i].Base = SE->getSubExpr(Uses[i].Base, CommonExprs);
continue;
}
I think this eliminates the need for the second hunk. Could this work?
-Chris
More information about the llvm-commits
mailing list