]> granicus.if.org Git - llvm/commitdiff
[AArch64] Minor code refactoring. NFC.
authorChad Rosier <mcrosier@codeaurora.org>
Wed, 25 Jan 2017 15:56:59 +0000 (15:56 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Wed, 25 Jan 2017 15:56:59 +0000 (15:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293063 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/AArch64RedundantCopyElimination.cpp

index 8f45e6a80a36056b723493e756705860d96b3a1a..45fd358a99bef96057f7682def7be4615bb53bd0 100644 (file)
@@ -70,14 +70,10 @@ static bool guaranteesZeroRegInBlock(MachineInstr &MI, MachineBasicBlock *MBB) {
   unsigned Opc = MI.getOpcode();
   // Check if the current basic block is the target block to which the
   // CBZ/CBNZ instruction jumps when its Wt/Xt is zero.
-  if ((Opc == AArch64::CBZW || Opc == AArch64::CBZX) &&
-      MBB == MI.getOperand(1).getMBB())
-    return true;
-  else if ((Opc == AArch64::CBNZW || Opc == AArch64::CBNZX) &&
-           MBB != MI.getOperand(1).getMBB())
-    return true;
-
-  return false;
+  return ((Opc == AArch64::CBZW || Opc == AArch64::CBZX) &&
+          MBB == MI.getOperand(1).getMBB()) ||
+         ((Opc == AArch64::CBNZW || Opc == AArch64::CBNZX) &&
+          MBB != MI.getOperand(1).getMBB());
 }
 
 bool AArch64RedundantCopyElimination::optimizeCopy(MachineBasicBlock *MBB) {
@@ -85,9 +81,14 @@ bool AArch64RedundantCopyElimination::optimizeCopy(MachineBasicBlock *MBB) {
   if (MBB->pred_size() != 1)
     return false;
 
+  // Check if the predecessor has two successors, implying the block ends in a
+  // conditional branch.
   MachineBasicBlock *PredMBB = *MBB->pred_begin();
+  if (PredMBB->succ_size() != 2)
+    return false;
+
   MachineBasicBlock::iterator CompBr = PredMBB->getLastNonDebugInstr();
-  if (CompBr == PredMBB->end() || PredMBB->succ_size() != 2)
+  if (CompBr == PredMBB->end())
     return false;
 
   ++CompBr;