[PATCH] D26450: [JumpThreading] Prevent non-deterministic use lists

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 02:34:19 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL286807: [JumpThreading] Prevent non-deterministic use lists (authored by pabbar01).

Changed prior to commit:
  https://reviews.llvm.org/D26450?vs=77610&id=77777#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26450

Files:
  llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp


Index: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
@@ -2042,19 +2042,18 @@
       // Look for scalar booleans used in selects as conditions. If there are
       // several selects that use the same boolean, they are candidates for jump
       // threading and therefore we should unfold them.
-      for (Value *U : I.users())
-        if (auto *SI = dyn_cast<SelectInst>(U))
+      for (Use& U : I.uses()) {
+        auto *SI = dyn_cast<SelectInst>(U.getUser());
+        if (SI && U.getOperandNo() == 0)
           Selects.push_back(SI);
+      }
+
       if (Selects.size() <= 1)
         continue;
 
-      // Remove duplicates
-      std::sort(Selects.begin(), Selects.end());
-      auto NewEnd = std::unique(Selects.begin(), Selects.end());
-
       Changed = true;
-      for (auto SI = Selects.begin(); SI != NewEnd; ++SI)
-        expandSelect(*SI);
+      for (auto SI : Selects)
+        expandSelect(SI);
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26450.77777.patch
Type: text/x-patch
Size: 1117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/f90bc158/attachment-0001.bin>


More information about the llvm-commits mailing list