[unroll] Replace a boolean, for loop, condition, and break with
authorChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:18:14 +0000 (04:18 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:18:14 +0000 (04:18 +0000)
std::all_of and a lambda. Much cleaner, no functionality
changed.

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

lib/Transforms/Scalar/LoopUnrollPass.cpp

index 4c57c922bc96225d74cc2d450d86c40451191935..ccc4a248476e3cea13fa309ac057360883f0566b 100644 (file)
@@ -542,14 +542,10 @@ public:
         continue;
       if (DeadInstructions.count(I))
         continue;
-      bool AllUsersFolded = true;
-      for (User *U : I->users())
-        if (!DeadInstructions.count(cast<Instruction>(U))) {
-          AllUsersFolded = false;
-          break;
-        }
 
-      if (AllUsersFolded) {
+      if (std::all_of(I->user_begin(), I->user_end(), [&](User *U) {
+            return DeadInstructions.count(cast<Instruction>(U));
+          })) {
         NumberOfOptimizedInstructions += TTI.getUserCost(I);
         DeadInstructions.insert(I);
         EnqueueOperands(*I);