Simplify check that optional def is there and is CPSR.
authorBill Wendling <isanbard@gmail.com>
Tue, 11 Oct 2011 00:10:41 +0000 (00:10 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 11 Oct 2011 00:10:41 +0000 (00:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/Thumb2ITBlockPass.cpp

index 2bf99bfd5c3dcd046cba9a4cc9da2d5f2491831f..b6274007b23731f4e710aeb524d5c831454d3cc6 100644 (file)
@@ -140,11 +140,10 @@ Thumb2ITBlockPass::MoveCopyOutOfITBlock(MachineInstr *MI,
   //   rsb   r1, 0
   //   rsb   r2, 0
   //
-  // 
-  for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I)
-    if (MI->getOperand(I).isReg() && MI->getOperand(I).getReg() == ARM::CPSR &&
-        MI->getOperand(I).isDef())
-      return false;
+  const MCInstrDesc &MCID = MI->getDesc();
+  if (MCID.hasOptionalDef() &&
+      MI->getOperand(MCID.getNumOperands() - 1).getReg() == ARM::CPSR)
+    return false;
 
   // Then peek at the next instruction to see if it's predicated on CC or OCC.
   // If not, then there is nothing to be gained by moving the copy.