]> granicus.if.org Git - llvm/commitdiff
[unroll] Directly query for dead instructions.
authorChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:14:05 +0000 (04:14 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:14:05 +0000 (04:14 +0000)
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.

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

lib/Transforms/Scalar/LoopUnrollPass.cpp

index 37851ba87da3a7c0b20d868639ecb7f08a02b2eb..4c57c922bc96225d74cc2d450d86c40451191935 100644 (file)
@@ -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);