[llvm-commits] [llvm] r141895 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll

Andrew Trick atrick at apple.com
Thu Oct 13 14:55:29 PDT 2011


Author: atrick
Date: Thu Oct 13 16:55:29 2011
New Revision: 141895

URL: http://llvm.org/viewvc/llvm-project?rev=141895&view=rev
Log:
Reapply r141870, SCEV expansion of post-inc.

Speculatively reapply to see if this test case still crashes on
linux. I may have fixed it in my last checkin.

Added:
    llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll
      - copied unchanged from r141872, llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll
Modified:
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=141895&r1=141894&r2=141895&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Thu Oct 13 16:55:29 2011
@@ -1120,6 +1120,14 @@
     BasicBlock *LatchBlock = L->getLoopLatch();
     assert(LatchBlock && "PostInc mode requires a unique loop latch!");
     Result = PN->getIncomingValueForBlock(LatchBlock);
+
+    // For an expansion to use the postinc form, the client must call
+    // expandCodeFor with an InsertPoint that is either outside the PostIncLoop
+    // or dominated by IVIncInsertPos.
+    assert((!isa<Instruction>(Result) ||
+            SE.DT->dominates(cast<Instruction>(Result),
+                             Builder.GetInsertPoint())) &&
+           "postinc expansion does not dominate use");
   }
 
   // Re-apply any non-loop-dominating scale.
@@ -1410,8 +1418,12 @@
   Value *V = visit(S);
 
   // Remember the expanded value for this SCEV at this location.
-  if (PostIncLoops.empty())
-    InsertedExpressions[std::make_pair(S, InsertPt)] = V;
+  //
+  // This is independent of PostIncLoops. The mapped value simply materializes
+  // the expression at this insertion point. If the mapped value happened to be
+  // a postinc expansion, it could be reused by a non postinc user, but only if
+  // its insertion point was already at the head of the loop.
+  InsertedExpressions[std::make_pair(S, InsertPt)] = V;
 
   restoreInsertPoint(SaveInsertBB, SaveInsertPt);
   return V;





More information about the llvm-commits mailing list