From 249ded3fa8884f91fded869fb6e251b8aebb0376 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sat, 23 Feb 2008 03:38:34 +0000 Subject: Rematerialization logic was overly conservative when it comes to loads from fixed stack slots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47529 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/LiveIntervalAnalysis.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp') diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index a18f36afb7..2ff8afdeb8 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -646,27 +646,9 @@ bool LiveIntervals::isReMaterializable(const LiveInterval &li, int FrameIdx = 0; if (tii_->isLoadFromStackSlot(MI, FrameIdx) && - mf_->getFrameInfo()->isImmutableObjectIndex(FrameIdx)) { - // This is a load from fixed stack slot. It can be rematerialized unless - // it's re-defined by a two-address instruction. - isLoad = true; - for (LiveInterval::const_vni_iterator i = li.vni_begin(), e = li.vni_end(); - i != e; ++i) { - const VNInfo *VNI = *i; - if (VNI == ValNo) - continue; - unsigned DefIdx = VNI->def; - if (DefIdx == ~1U) - continue; // Dead val#. - MachineInstr *DefMI = (DefIdx == ~0u) - ? NULL : getInstructionFromIndex(DefIdx); - if (DefMI && DefMI->isRegReDefinedByTwoAddr(li.reg)) { - isLoad = false; - return false; - } - } + mf_->getFrameInfo()->isImmutableObjectIndex(FrameIdx)) + // This is a load from fixed stack slot. It can be rematerialized. return true; - } if (tii_->isTriviallyReMaterializable(MI)) { isLoad = TID.isSimpleLoad(); @@ -754,6 +736,10 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI, FoldOps.push_back(OpIdx); } + // Can't fold a load from fixed stack slot into a two address instruction. + if (isSS && DefMI && (MRInfo & VirtRegMap::isMod)) + return false; + MachineInstr *fmi = isSS ? tii_->foldMemoryOperand(*mf_, MI, FoldOps, Slot) : tii_->foldMemoryOperand(*mf_, MI, FoldOps, DefMI); if (fmi) { -- cgit v1.2.3