[llvm-commits] [llvm] r100285 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
Chris Lattner
sabre at nondot.org
Sat Apr 3 00:21:39 PDT 2010
Author: lattner
Date: Sat Apr 3 02:21:39 2010
New Revision: 100285
URL: http://llvm.org/viewvc/llvm-project?rev=100285&view=rev
Log:
require that the branch being controlled by the IV
exits the loop. With this information we can guarantee
the iteration count of the loop is bounded by the
compare. I think this xforms is finally safe now.
Modified:
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=100285&r1=100284&r2=100285&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Sat Apr 3 02:21:39 2010
@@ -691,8 +691,15 @@
BranchInst *TheBr = cast<BranchInst>(Compare->use_back());
- // FIXME: Need to verify that the branch actually controls the iteration count
- // of the loop. If not, the new IV can overflow and noone will notice.
+ // We need to verify that the branch actually controls the iteration count
+ // of the loop. If not, the new IV can overflow and no one will notice.
+ // The branch block must be in the loop and one of the successors must be out
+ // of the loop.
+ assert(TheBr->isConditional() && "Can't use fcmp if not conditional");
+ if (!L->contains(TheBr->getParent()) ||
+ (L->contains(TheBr->getSuccessor(0)) &&
+ L->contains(TheBr->getSuccessor(1))))
+ return;
// If it isn't a comparison with an integer-as-fp (the exit value), we can't
More information about the llvm-commits
mailing list