Use MRI::isConstantPhysReg() to check remat feasibility.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 22 Jun 2012 17:31:01 +0000 (17:31 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 22 Jun 2012 17:31:01 +0000 (17:31 +0000)
Don't depend on LiveIntervals::hasInterval() to determine if a physreg
is reserved and constant.

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

lib/CodeGen/LiveRangeEdit.cpp

index 434388b94efee9997d6eb4d2347ab96a2c619a5d..261d860e015260d5f3f6cb721b86d407d3dbe0f5 100644 (file)
@@ -82,12 +82,16 @@ bool LiveRangeEdit::allUsesAvailableAt(const MachineInstr *OrigMI,
   UseIdx = UseIdx.getRegSlot(true);
   for (unsigned i = 0, e = OrigMI->getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = OrigMI->getOperand(i);
-    if (!MO.isReg() || !MO.getReg() || MO.isDef())
-      continue;
-    // Reserved registers are OK.
-    if (MO.isUndef() || !LIS.hasInterval(MO.getReg()))
+    if (!MO.isReg() || !MO.getReg() || !MO.readsReg())
       continue;
 
+    // We can't remat physreg uses, unless it is a constant.
+    if (TargetRegisterInfo::isPhysicalRegister(MO.getReg())) {
+      if (MRI.isConstantPhysReg(MO.getReg(), VRM->getMachineFunction()))
+        continue;
+      return false;
+    }
+
     LiveInterval &li = LIS.getInterval(MO.getReg());
     const VNInfo *OVNI = li.getVNInfoAt(OrigIdx);
     if (!OVNI)