[unroll] Don't check the loop set for whether an instruction is
authorChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:30:44 +0000 (04:30 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 04:30:44 +0000 (04:30 +0000)
contained in it each time we try to add it to the worklist, just check
this when pulling it off the worklist. That way we do it at most once
per instruction with the cost of the worklist set we would need to pay
anyways.

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

lib/Transforms/Scalar/LoopUnrollPass.cpp

index 0851f436904e184a4c71a8144affe3dc4053ea76..8cf0450dd9ed1b88829abb547e64a7ec5a8d2b18 100644 (file)
@@ -472,8 +472,6 @@ public:
         Instruction *UI = dyn_cast<Instruction>(U);
         if (!UI)
           continue;
-        if (!L->contains(UI))
-          continue;
         Worklist.insert(UI);
       }
     }
@@ -483,14 +481,14 @@ public:
     // its users as well.
     while (!Worklist.empty()) {
       Instruction *I = Worklist.pop_back_val();
+      if (!L->contains(I))
+        continue;
       if (!visit(I))
         continue;
       for (User *U : I->users()) {
         Instruction *UI = dyn_cast<Instruction>(U);
         if (!UI)
           continue;
-        if (!L->contains(UI))
-          continue;
         Worklist.insert(UI);
       }
     }