diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-09-06 05:33:18 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-09-06 05:33:18 +0000 |
commit | 6f86e001d6d3932322d7b4c303a9688540c9da1b (patch) | |
tree | a1d28a18cc1e3bccc37c5c24df8796f675f01687 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | db66b82dd544c8b693c2ea14170a822ae718f9e2 (diff) | |
download | bcm5719-llvm-6f86e001d6d3932322d7b4c303a9688540c9da1b.tar.gz bcm5719-llvm-6f86e001d6d3932322d7b4c303a9688540c9da1b.zip |
Fix flipped sign. While there, show my math.
llvm-svn: 139135
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index c64cdf89ccb..9f8b5c5dfe5 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -1976,7 +1976,13 @@ 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. + // + // 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) if (const SCEVAddRecExpr *OtherAddRec = @@ -1989,7 +1995,8 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, const SCEV *NewStart = getMulExpr(A, C); const SCEV *BD = getMulExpr(B, D); const SCEV *NewStep = getAddExpr(getMulExpr(A, D), - getMulExpr(B, C), BD); + getMulExpr(B, C), + getNegativeSCEV(BD)); const SCEV *NewSecondOrderStep = getMulExpr(BD, getConstant(BD->getType(), 2)); |