[llvm-commits] [llvm] r47520 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Evan Cheng evan.cheng at apple.com
Fri Feb 22 17:44:27 PST 2008


Author: evancheng
Date: Fri Feb 22 19:44:27 2008
New Revision: 47520

URL: http://llvm.org/viewvc/llvm-project?rev=47520&view=rev
Log:
Recognize loads of arguments as re-materializable first. Therefore if isReallyTriviallyReMaterializable() returns true it doesn't confuse it as a "normal" re-materializable instruction.

Modified:
    llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=47520&r1=47519&r2=47520&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Feb 22 19:44:27 2008
@@ -643,6 +643,31 @@
   const TargetInstrDesc &TID = MI->getDesc();
   if (TID.isImplicitDef())
     return true;
+
+  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;
+      }
+    }
+    return true;
+  }
+
   if (tii_->isTriviallyReMaterializable(MI)) {
     isLoad = TID.isSimpleLoad();
 
@@ -663,30 +688,7 @@
     return true;
   }
 
-  int FrameIdx = 0;
-  if (!tii_->isLoadFromStackSlot(MI, FrameIdx) ||
-      !mf_->getFrameInfo()->isImmutableObjectIndex(FrameIdx))
-    return false;
-
-  // 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;
-    }
-  }
-  return true;
+  return false;
 }
 
 /// isReMaterializable - Returns true if every definition of MI of every





More information about the llvm-commits mailing list