Machine LICM will check that operands are defined outside of the loop. Also
authorBill Wendling <isanbard@gmail.com>
Wed, 2 Jan 2008 21:10:40 +0000 (21:10 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 2 Jan 2008 21:10:40 +0000 (21:10 +0000)
check that register isn't 0 before going further.

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

lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h

index 1c79209bf1ba7f14a45d336d7a294adc254e3733..577b937490115b4d1a0150920555ed160acb50c7 100644 (file)
@@ -144,37 +144,6 @@ bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const {
   return true;
 }
 
-/// isDefinedInEntryBlock - Goes through the entry block to see if the given
-/// virtual register is indeed defined in the entry block.
-/// 
-bool X86InstrInfo::isDefinedInEntryBlock(const MachineBasicBlock &Entry,
-                                         unsigned VReg) const {
-  assert(MRegisterInfo::isVirtualRegister(VReg) &&
-         "Map only holds virtual registers!");
-  MachineInstrMap.grow(VReg);
-  if (MachineInstrMap[VReg]) return true;
-
-  MachineBasicBlock::const_iterator I = Entry.begin(), E = Entry.end();
-
-  for (; I != E; ++I) {
-    const MachineInstr &MI = *I;
-    unsigned NumOps = MI.getNumOperands();
-
-    for (unsigned i = 0; i < NumOps; ++i) {
-      const MachineOperand &MO = MI.getOperand(i);
-
-      if(MO.isRegister() && MO.isDef() &&
-         MRegisterInfo::isVirtualRegister(MO.getReg()) &&
-         MO.getReg() == VReg) {
-        MachineInstrMap[VReg] = &MI;
-        return true;
-      }
-    }
-  }
-
-  return false;
-}
-
 /// isReallySideEffectFree - If the M_MAY_HAVE_SIDE_EFFECTS flag is set, this
 /// method is called to determine if the specific instance of this instruction
 /// has side effects. This is useful in cases of instructions, like loads, which
@@ -189,8 +158,7 @@ bool X86InstrInfo::isReallySideEffectFree(MachineInstr *MI) const {
 
       // Loads from global addresses which aren't redefined in the function are
       // side effect free.
-      if (MRegisterInfo::isVirtualRegister(Reg) &&
-          isDefinedInEntryBlock(MI->getParent()->getParent()->front(), Reg) &&
+      if (Reg != 0 && MRegisterInfo::isVirtualRegister(Reg) &&
           MI->getOperand(2).isImmediate() &&
           MI->getOperand(3).isRegister() &&
           MI->getOperand(4).isGlobalAddress() &&
index 4a6a3a085c90bec62724cbced99ffd93b72ef250..280d040c6ad588ef8501601299e27a1932eaeab1 100644 (file)
@@ -225,13 +225,6 @@ namespace X86II {
 class X86InstrInfo : public TargetInstrInfoImpl {
   X86TargetMachine &TM;
   const X86RegisterInfo RI;
-  mutable IndexedMap<const MachineInstr*, VirtReg2IndexFunctor> MachineInstrMap;
-
-  /// isDefinedInEntryBlock - Goes through the entry block to see if the given
-  /// virtual register is indeed defined in the entry block.
-  /// 
-  bool isDefinedInEntryBlock(const MachineBasicBlock &Entry,
-                             unsigned VReg) const;
 public:
   X86InstrInfo(X86TargetMachine &tm);