Add new TargetInstrDesc::hasImplicitUseOfPhysReg and
authorChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 07:26:51 +0000 (07:26 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 07:26:51 +0000 (07:26 +0000)
hasImplicitDefOfPhysReg methods.  Use them to remove a
look in X86 fast isel.

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

include/llvm/Target/TargetInstrDesc.h
lib/Target/X86/X86FastISel.cpp

index b389a4f746cea4692c88f3499c75902a1b9c290c..622a216c33c63f6e775c1b20a52587667e7e980e 100644 (file)
@@ -199,6 +199,24 @@ public:
   const unsigned *getImplicitDefs() const {
     return ImplicitDefs;
   }
+  
+  /// hasImplicitUseOfPhysReg - Return true if this instruction implicitly
+  /// uses the specified physical register.
+  bool hasImplicitUseOfPhysReg(unsigned Reg) const {
+    if (const unsigned *ImpUses = ImplicitUses)
+      for (; *ImpUses; ++ImpUses)
+        if (*ImpUses == Reg) return true;
+    return false;
+  }
+  
+  /// hasImplicitDefOfPhysReg - Return true if this instruction implicitly
+  /// defines the specified physical register.
+  bool hasImplicitDefOfPhysReg(unsigned Reg) const {
+    if (const unsigned *ImpDefs = ImplicitDefs)
+      for (; *ImpDefs; ++ImpDefs)
+        if (*ImpDefs == Reg) return true;
+    return false;
+  }
 
   /// getRegClassBarriers - Return a list of register classes that are
   /// completely clobbered by this machine instruction. For example, on X86
index 7b114ddbc381142516af277775037e97dc207ab4..0146b0730dea390411f51c5ba52b227263340688 100644 (file)
@@ -808,21 +808,9 @@ bool X86FastISel::X86SelectBranch(Instruction *I) {
             }
 
             const TargetInstrDesc &TID = MI.getDesc();
-            const unsigned *ImpDefs = TID.getImplicitDefs();
-
-            if (TID.hasUnmodeledSideEffects()) break;
-
-            bool ModifiesEFlags = false;
-
-            if (ImpDefs) {
-              for (unsigned u = 0; ImpDefs[u]; ++u)
-                if (ImpDefs[u] == X86::EFLAGS) {
-                  ModifiesEFlags = true;
-                  break;
-                }
-            }
-
-            if (ModifiesEFlags) break;
+            if (TID.hasUnmodeledSideEffects() ||
+                TID.hasImplicitDefOfPhysReg(X86::EFLAGS))
+              break;
           }
 
           if (SetMI) {