Set the insertion point correctly for instructions generated by load folding:
authorChris Lattner <sabre@nondot.org>
Fri, 14 Jan 2011 01:33:40 +0000 (01:33 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 14 Jan 2011 01:33:40 +0000 (01:33 +0000)
they should go *before* the new instruction not after it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123420 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 4ac3257ecbe265d5cb3ee51c3304979133431147..6a999c2dc9f4ffef3b5741030c19845bc2d56c28 100644 (file)
@@ -890,10 +890,10 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
           if (Inst != Begin)
             BeforeInst = llvm::prior(llvm::prior(BI));
           if (BeforeInst && isa<LoadInst>(BeforeInst) &&
-              BeforeInst->hasOneUse() && *BeforeInst->use_begin() == Inst &&
-              TryToFoldFastISelLoad(cast<LoadInst>(BeforeInst), FastIS)) {
-            // If we succeeded, don't re-select the load.
-            --BI;
+              BeforeInst->hasOneUse() && *BeforeInst->use_begin() == Inst) {
+            FastIS->recomputeInsertPt();
+            if (TryToFoldFastISelLoad(cast<LoadInst>(BeforeInst), FastIS))
+              --BI; // If we succeeded, don't re-select the load.
           }
           continue;
         }