diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-08-30 05:53:02 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-08-30 05:53:02 +0000 |
commit | 34c2a9f57ccf57f341ad27cef59e4c5eb2253e1d (patch) | |
tree | 2acea29a296d7930913e68f3e5e46b2a9cfca124 /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | 35b35c5c320a71e4611fe2101452da685f8eeda0 (diff) | |
download | external_llvm-34c2a9f57ccf57f341ad27cef59e4c5eb2253e1d.zip external_llvm-34c2a9f57ccf57f341ad27cef59e4c5eb2253e1d.tar.gz external_llvm-34c2a9f57ccf57f341ad27cef59e4c5eb2253e1d.tar.bz2 |
Try fold re-materialized load instructions into its uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41598 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 7958ab7..25de7c3 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -236,10 +236,17 @@ bool LiveIntervals::isReMaterializable(const LiveInterval &li, return true; } +/// tryFoldMemoryOperand - Attempts to fold either a spill / restore from +/// slot / to reg or any rematerialized load into ith operand of specified +/// MI. If it is successul, MI is updated with the newly created MI and +/// returns true. bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, unsigned index, unsigned i, + bool isSS, MachineInstr *DefMI, int slot, unsigned reg) { - MachineInstr *fmi = mri_->foldMemoryOperand(MI, i, slot); + MachineInstr *fmi = isSS + ? mri_->foldMemoryOperand(MI, i, slot) + : mri_->foldMemoryOperand(MI, i, DefMI); if (fmi) { // Attempt to fold the memory reference into the instruction. If // we can do this, we don't need to insert spill code. @@ -340,6 +347,8 @@ addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, unsigned reg) { bool CanDelete = ReMatDelete[I->valno->id]; int LdSlot = 0; bool isLoadSS = DefIsReMat && tii_->isLoadFromStackSlot(DefMI, LdSlot); + bool isLoad = isLoadSS || + (DefIsReMat && (DefMI->getInstrDescriptor()->Flags & M_LOAD_FLAG)); unsigned index = getBaseIndex(I->start); unsigned end = getBaseIndex(I->end-1) + InstrSlots::NUM; for (; index != end; index += InstrSlots::NUM) { @@ -362,20 +371,22 @@ addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, unsigned reg) { RemoveMachineInstrFromMaps(MI); MI->eraseFromParent(); break; - } else if (tryFoldMemoryOperand(MI, vrm, index, i, slot, li.reg)) + } else if (tryFoldMemoryOperand(MI, vrm, index, i, true, + DefMI, slot, li.reg)) { // Folding the load/store can completely change the instruction // in unpredictable ways, rescan it from the beginning. goto RestartInstruction; - } else if (isLoadSS && - tryFoldMemoryOperand(MI, vrm, index, i, LdSlot, li.reg)){ - // FIXME: Other rematerializable loads can be folded as well. - // Folding the load/store can completely change the - // instruction in unpredictable ways, rescan it from - // the beginning. - goto RestartInstruction; - } + } + } else if (isLoad && + tryFoldMemoryOperand(MI, vrm, index, i, isLoadSS, + DefMI, LdSlot, li.reg)) + // Folding the load/store can completely change the + // instruction in unpredictable ways, rescan it from + // the beginning. + goto RestartInstruction; } else { - if (tryFoldMemoryOperand(MI, vrm, index, i, slot, li.reg)) + if (tryFoldMemoryOperand(MI, vrm, index, i, true, DefMI, + slot, li.reg)) // Folding the load/store can completely change the instruction in // unpredictable ways, rescan it from the beginning. goto RestartInstruction; |