[llvm] r229056 - [unroll] Replace a linear time check for no uses with a constant time

Chandler Carruth chandlerc at gmail.com
Thu Feb 12 20:06:08 PST 2015


Author: chandlerc
Date: Thu Feb 12 22:06:08 2015
New Revision: 229056

URL: http://llvm.org/viewvc/llvm-project?rev=229056&view=rev
Log:
[unroll] Replace a linear time check for no uses with a constant time
check.

Also hoist this into the enqueue process as it is faster even than
testing the worklist set, we should just directly filter these out much
like we filter out constants and such.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=229056&r1=229055&r2=229056&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Thu Feb 12 22:06:08 2015
@@ -519,7 +519,8 @@ public:
     auto EnqueueOperands = [&](Instruction &I) {
       for (auto *Op : I.operand_values())
         if (auto *OpI = dyn_cast<Instruction>(Op))
-          Worklist.insert(OpI);
+          if (!OpI->use_empty())
+            Worklist.insert(OpI);
     };
 
     // Start by initializing worklist with simplified instructions.
@@ -541,8 +542,6 @@ public:
         continue;
       if (DeadInstructions.count(I))
         continue;
-      if (I->getNumUses() == 0)
-        continue;
       bool AllUsersFolded = true;
       for (User *U : I->users()) {
         Instruction *UI = dyn_cast<Instruction>(U);





More information about the llvm-commits mailing list