[llvm] r293063 - [AArch64] Minor code refactoring. NFC.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 07:56:59 PST 2017


Author: mcrosier
Date: Wed Jan 25 09:56:59 2017
New Revision: 293063

URL: http://llvm.org/viewvc/llvm-project?rev=293063&view=rev
Log:
[AArch64] Minor code refactoring. NFC.

Modified:
    llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp?rev=293063&r1=293062&r2=293063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp Wed Jan 25 09:56:59 2017
@@ -70,14 +70,10 @@ static bool guaranteesZeroRegInBlock(Mac
   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::op
   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;




More information about the llvm-commits mailing list