diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-09 22:31:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-09 22:31:26 +0000 |
commit | ad19c8c63cae112a2677c2f5d65717aeba44f8cb (patch) | |
tree | ceb256c7a5a055278ed5f962644243d463620721 /lib/Analysis/ScalarEvolution.cpp | |
parent | 992efb03785f2a368fbb63b09373be1d6a96ce5a (diff) |
Step #3 to improving trip count analysis: If we fold
a + {b,+,stride} into {a+b,+,stride} (because a is LIV),
then the resultant AddRec is NUW/NSW if the client says it
is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index d3d65847cb..89daec8053 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1560,10 +1560,14 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, AddRecOps[0] = getAddExpr(LIOps); // Build the new addrec. Propagate the NUW and NSW flags if both the - // outer add and the inner addrec are guaranteed to have no overflow. - const SCEV *NewRec = getAddRecExpr(AddRecOps, AddRecLoop, - HasNUW && AddRec->hasNoUnsignedWrap(), - HasNSW && AddRec->hasNoSignedWrap()); + // outer add and the inner addrec are guaranteed to have no overflow or if + // there is no outer part. + if (Ops.size() != 1) { + HasNUW &= AddRec->hasNoUnsignedWrap(); + HasNSW &= AddRec->hasNoSignedWrap(); + } + + const SCEV *NewRec = getAddRecExpr(AddRecOps, AddRecLoop, HasNUW, HasNSW); // If all of the other operands were loop invariant, we are done. if (Ops.size() == 1) return NewRec; |