Add getTPred() and getFPred() functions.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 10 Aug 2012 20:19:17 +0000 (20:19 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 10 Aug 2012 20:19:17 +0000 (20:19 +0000)
They identify the PHI predecessors in both diamonds and triangles.

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

lib/CodeGen/EarlyIfConversion.cpp

index b7ad8a429e572aeff2e94dbc80e30ef22c2ffcf4..3b7f8796cd3f4c8bcb6e335e92401c176706cc20 100644 (file)
@@ -96,6 +96,12 @@ public:
   /// equal to Tail.
   bool isTriangle() const { return TBB == Tail || FBB == Tail; }
 
+  /// Returns the Tail predecessor for the True side.
+  MachineBasicBlock *getTPred() const { return TBB == Tail ? Head : TBB; }
+
+  /// Returns the Tail predecessor for the  False side.
+  MachineBasicBlock *getFPred() const { return FBB == Tail ? Head : FBB; }
+
   /// Information about each phi in the Tail block.
   struct PHIInfo {
     MachineInstr *PHI;
@@ -391,8 +397,8 @@ bool SSAIfConv::canConvertIf(MachineBasicBlock *MBB) {
 
   // Any phis in the tail block must be convertible to selects.
   PHIs.clear();
-  MachineBasicBlock *TPred = TBB == Tail ? Head : TBB;
-  MachineBasicBlock *FPred = FBB == Tail ? Head : FBB;
+  MachineBasicBlock *TPred = getTPred();
+  MachineBasicBlock *FPred = getFPred();
   for (MachineBasicBlock::iterator I = Tail->begin(), E = Tail->end();
        I != E && I->isPHI(); ++I) {
     PHIs.push_back(&*I);