[llvm-commits] [llvm] r123133 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Chris Lattner
sabre at nondot.org
Sun Jan 9 14:31:26 PST 2011
Author: lattner
Date: Sun Jan 9 16:31:26 2011
New Revision: 123133
URL: http://llvm.org/viewvc/llvm-project?rev=123133&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=123133&r1=123132&r2=123133&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sun Jan 9 16:31:26 2011
@@ -1560,10 +1560,14 @@
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;
More information about the llvm-commits
mailing list