diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-01-16 02:27:38 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-01-16 02:27:38 +0000 |
| commit | 2d186574a690f7957e5f77cd167f9b4648e8b4b4 (patch) | |
| tree | 65fba0a007ea6aaa7b2940a4f875ab44b8fee6e6 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 8b4952fcf722d4beafa057e0d65bec996dc46cc6 (diff) | |
| download | bcm5719-llvm-2d186574a690f7957e5f77cd167f9b4648e8b4b4.tar.gz bcm5719-llvm-2d186574a690f7957e5f77cd167f9b4648e8b4b4.zip | |
reapply my fix for PR8961 with a tweak to properly handle
multi-instruction sequences like calls. Many thanks to Jakob for
finding a testcase.
llvm-svn: 123559
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index f5f267cb070..ae63f2e657f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -771,8 +771,16 @@ bool SelectionDAGISel::TryToFoldFastISelLoad(const LoadInst *LI, assert(RI.getOperand().isUse() && "The only use of the vreg must be a use, we haven't emitted the def!"); + MachineInstr *User = &*RI; + + // Set the insertion point properly. Folding the load can cause generation of + // other random instructions (like sign extends) for addressing modes, make + // sure they get inserted in a logical place before the new instruction. + FuncInfo->InsertPt = User; + FuncInfo->MBB = User->getParent(); + // Ask the target to try folding the load. - return FastIS->TryToFoldLoad(&*RI, RI.getOperandNo(), LI); + return FastIS->TryToFoldLoad(User, RI.getOperandNo(), LI); } #ifndef NDEBUG @@ -890,11 +898,9 @@ 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) { - FastIS->recomputeInsertPt(); - if (TryToFoldFastISelLoad(cast<LoadInst>(BeforeInst), FastIS)) - --BI; // If we succeeded, don't re-select the load. - } + BeforeInst->hasOneUse() && *BeforeInst->use_begin() == Inst && + TryToFoldFastISelLoad(cast<LoadInst>(BeforeInst), FastIS)) + --BI; // If we succeeded, don't re-select the load. continue; } |

