[llvm] r280231 - Revert "[SimplifyCFG] Fix bootstrap failure after r280220"

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 06:16:30 PDT 2016


Author: jamesm
Date: Wed Aug 31 08:16:30 2016
New Revision: 280231

URL: http://llvm.org/viewvc/llvm-project?rev=280231&view=rev
Log:
Revert "[SimplifyCFG] Fix bootstrap failure after r280220"

This reverts commit r280228. r280216 caused buildbot failures - backing out the entire sequence.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/test/Transforms/SimplifyCFG/sink-common-code.ll

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=280231&r1=280230&r2=280231&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Aug 31 08:16:30 2016
@@ -1444,7 +1444,7 @@ static bool canSinkInstructions(
 // Assuming canSinkLastInstruction(Blocks) has returned true, sink the last
 // instruction of every block in Blocks to their common successor, commoning
 // into one instruction.
-static bool sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) {
+static void sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) {
   auto *BBEnd = Blocks[0]->getTerminator()->getSuccessor(0);
 
   // canSinkLastInstruction returning true guarantees that every block has at
@@ -1453,22 +1453,9 @@ static bool sinkLastInstruction(ArrayRef
   for (auto *BB : Blocks)
     Insts.push_back(BB->getTerminator()->getPrevNode());
 
-  // The only checking we need to do now is that all users of all instructions
-  // are the same PHI node. canSinkLastInstruction should have checked this but
-  // it is slightly over-aggressive - it gets confused by commutative instructions
-  // so double-check it here.
+  // We don't need to do any checking here; canSinkLastInstruction should have
+  // done it all for us.
   Instruction *I0 = Insts.front();
-  if (!isa<StoreInst>(I0)) {
-    auto *PNUse = dyn_cast<PHINode>(*I0->user_begin());
-    if (!all_of(Insts, [&PNUse](const Instruction *I) -> bool {
-          auto *U = cast<Instruction>(*I->user_begin());
-          return U == PNUse || U->getParent() == I->getParent();
-        }))
-      return false;
-  }
-  
-  // We don't need to do any more checking here; canSinkLastInstruction should
-  // have done it all for us.
   SmallVector<Value*, 4> NewOperands;
   for (unsigned O = 0, E = I0->getNumOperands(); O != E; ++O) {
     // This check is different to that in canSinkLastInstruction. There, we
@@ -1520,8 +1507,6 @@ static bool sinkLastInstruction(ArrayRef
   for (auto *I : Insts)
     if (I != I0)
       I->eraseFromParent();
-
-  return true;
 }
 
 namespace {
@@ -1654,7 +1639,7 @@ static bool SinkThenElseCodeToEnd(Branch
   LockstepReverseIterator LRI(UnconditionalPreds);
   while (LRI.isValid() &&
          canSinkInstructions(*LRI, PHIOperands)) {
-    DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0] << "\n");
+    DEBUG(dbgs() << "SINK: instruction can be sunk: " << (*LRI)[0] << "\n");
     InstructionsToSink.insert((*LRI).begin(), (*LRI).end());
     ++ScanIdx;
     --LRI;
@@ -1713,8 +1698,7 @@ static bool SinkThenElseCodeToEnd(Branch
       break;
     }
     
-    if (!sinkLastInstruction(UnconditionalPreds))
-      return Changed;
+    sinkLastInstruction(UnconditionalPreds);
     NumSinkCommons++;
     Changed = true;
   }

Modified: llvm/trunk/test/Transforms/SimplifyCFG/sink-common-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/sink-common-code.ll?rev=280231&r1=280230&r2=280231&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/sink-common-code.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/sink-common-code.ll Wed Aug 31 08:16:30 2016
@@ -560,29 +560,6 @@ if.end:
 ; CHECK: store
 ; CHECK: store
 
-define zeroext i1 @test19(i1 zeroext %flag, i32* %i4, i32* %m, i32* %n) {
-entry:
-  br i1 %flag, label %if.then, label %if.else
-
-if.then:
-  %tmp1 = load i32, i32* %i4
-  %tmp2 = add i32 %tmp1, -1
-  store i32 %tmp2, i32* %i4
-  br label %if.end
-
-if.else:
-  %tmp3 = load i32, i32* %m
-  %tmp4 = load i32, i32* %n
-  %tmp5 = add i32 %tmp3, %tmp4
-  store i32 %tmp5, i32* %i4
-  br label %if.end
-
-if.end:
-  ret i1 true
-}
-
-; No checks for test19 - just ensure it doesn't crash!
-
 ; CHECK: !0 = !{!1, !1, i64 0}
 ; CHECK: !1 = !{!"float", !2}
 ; CHECK: !2 = !{!"an example type tree"}




More information about the llvm-commits mailing list