Index: lib/Transforms/Scalar/JumpThreading.cpp =================================================================== --- lib/Transforms/Scalar/JumpThreading.cpp +++ lib/Transforms/Scalar/JumpThreading.cpp @@ -15,6 +15,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/GlobalsModRef.h" @@ -2037,24 +2038,20 @@ if (I.getType()->isIntegerTy(1)) { - SmallVector Selects; + SmallSetVector Selects; // 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(U)) - Selects.push_back(SI); + Selects.insert(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); } }