Use the "isCompare" machine instruction attribute instead of calling the
relatively expensive comparison analyzer on each instruction. Also rename the
comparison analyzer method to something more in line with what it actually does.

This pass is will eventually be folded into the Machine CSE pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110539 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/OptimizeCmps.cpp b/lib/CodeGen/OptimizeCmps.cpp
index 5b524cd..209c8b9 100644
--- a/lib/CodeGen/OptimizeCmps.cpp
+++ b/lib/CodeGen/OptimizeCmps.cpp
@@ -72,9 +72,8 @@
   // physical register, we can try to optimize it.
   unsigned SrcReg;
   int CmpValue;
-  if (!TII->isCompareInstr(MI, SrcReg, CmpValue) ||
-      TargetRegisterInfo::isPhysicalRegister(SrcReg) ||
-      CmpValue != 0)
+  if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) ||
+      TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0)
     return false;
 
   MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg);
@@ -83,7 +82,7 @@
     return false;
 
   // Attempt to convert the defining instruction to set the "zero" flag.
-  if (TII->convertToSetZeroFlag(&*DI, MI)) {
+  if (TII->ConvertToSetZeroFlag(&*DI, MI)) {
     ++NumEliminated;
     return true;
   }
@@ -104,7 +103,8 @@
     for (MachineBasicBlock::iterator
            MII = MBB->begin(), ME = MBB->end(); MII != ME; ) {
       MachineInstr *MI = &*MII++;
-      Changed |= OptimizeCmpInstr(MI, MBB);
+      if (MI->getDesc().isCompare())
+        Changed |= OptimizeCmpInstr(MI, MBB);
     }
   }