summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 05ac11fc376..c37659b01f7 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -2042,19 +2042,18 @@ 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 (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);
}
}
OpenPOWER on IntegriCloud