diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-09-06 06:39:54 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-09-06 06:39:54 +0000 |
commit | 8cfb2f8bcec2af1c3228fb4e372d4dfb0010c37d (patch) | |
tree | 494998277965af89fd7802e7f8bd16a78d8bfcf0 /lib/Analysis/ScalarEvolution.cpp | |
parent | 28682ae00f6d6f71c325de2b1d80c0b7a8df0716 (diff) | |
download | external_llvm-8cfb2f8bcec2af1c3228fb4e372d4dfb0010c37d.zip external_llvm-8cfb2f8bcec2af1c3228fb4e372d4dfb0010c37d.tar.gz external_llvm-8cfb2f8bcec2af1c3228fb4e372d4dfb0010c37d.tar.bz2 |
Nope! I had it right the first time. Revert the operative part of r139135 and
add more showing of my work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 9f8b5c5..aba1934 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -652,7 +652,7 @@ static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops, /// Assume, K > 0. static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K, ScalarEvolution &SE, - Type* ResultTy) { + Type *ResultTy) { // Handle the simplest case efficiently. if (K == 1) return SE.getTruncateOrZeroExtend(It, ResultTy); @@ -1976,12 +1976,15 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); ++OtherIdx) if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) { - // {A,+,B}<L> * {C,+,D}<L> --> {A*C,+,A*D + B*C - B*D,+,2*B*D}<L> + // {A,+,B}<L> * {C,+,D}<L> --> {A*C,+,A*D + B*C + B*D,+,2*B*D}<L> // - // For reference, given that {X,+,Y,+,Z} = x + y*It + z*It^2 then - // X = x, Y = y-z, Z = 2z. + // {A,+,B} * {C,+,D} = A+It*B * C+It*D = A*C + (A*D + B*C)*It + B*D*It^2 + // Given an equation of the form x + y*It + z*It^2 (above), we want to + // express it in terms of {X,+,Y,+,Z}. + // {X,+,Y,+,Z} = X + Y*It + Z*(It^2 - It)/2. + // Rearranging, X = x, Y = x+y, Z = 2z. // - // x = A*C, y = (A*D + B*C), z = B*D + // x = A*C, y = (A*D + B*C), z = B*D. // Therefore X = A*C, Y = (A*D + B*C) - B*D and Z = 2*B*D. for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); ++OtherIdx) |