[llvm] r229057 - [unroll] Directly query for dead instructions.

Chandler Carruth chandlerc at gmail.com
Thu Feb 12 20:14:05 PST 2015


Author: chandlerc
Date: Thu Feb 12 22:14:05 2015
New Revision: 229057

URL: http://llvm.org/viewvc/llvm-project?rev=229057&view=rev
Log:
[unroll] Directly query for dead instructions.

In the unroll analyzer, it is checking each user to see if that user
will become dead. However, it first checked if that user was missing
from the simplified values map, and then if was also missing from the
dead instructions set. We add everything from the simplified values map
to the dead instructions set, so the first step is completely subsumed
by the second. Moreover, the first step requires *inserting* something
into the simplified value map which isn't what we want at all.

This also replaces a dyn_cast with a cast as an instruction cannot be
used by a non-instruction.

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=229057&r1=229056&r2=229057&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Thu Feb 12 22:14:05 2015
@@ -543,13 +543,12 @@ public:
       if (DeadInstructions.count(I))
         continue;
       bool AllUsersFolded = true;
-      for (User *U : I->users()) {
-        Instruction *UI = dyn_cast<Instruction>(U);
-        if (!SimplifiedValues[UI] && !DeadInstructions.count(UI)) {
+      for (User *U : I->users())
+        if (!DeadInstructions.count(cast<Instruction>(U))) {
           AllUsersFolded = false;
           break;
         }
-      }
+
       if (AllUsersFolded) {
         NumberOfOptimizedInstructions += TTI.getUserCost(I);
         DeadInstructions.insert(I);





More information about the llvm-commits mailing list