From: Pablo Barrio Date: Tue, 15 Nov 2016 15:42:17 +0000 (+0000) Subject: Revert "[JumpThreading] Prevent non-deterministic use lists" X-Git-Tag: llvmorg-4.0.0-rc1~4538 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f782bb0489046017c7023287e4592c0f2b71758;p=platform%2Fupstream%2Fllvm.git Revert "[JumpThreading] Prevent non-deterministic use lists" This reverts commit f2c2f5354070469dac253373c66527ca971ddc66. llvm-svn: 286975 --- diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index c37659b..05ac11f 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -2042,18 +2042,19 @@ bool JumpThreadingPass::TryToUnfoldSelectInCurrBB(BasicBlock *BB) { // 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 (Use& U : I.uses()) { - auto *SI = dyn_cast(U.getUser()); - if (SI && U.getOperandNo() == 0) + for (Value *U : I.users()) + if (auto *SI = dyn_cast(U)) 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) - expandSelect(SI); + for (auto SI = Selects.begin(); SI != NewEnd; ++SI) + expandSelect(*SI); } }