aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
diff options
context:
space:
mode:
authorJoshua Cao <cao.joshua@yahoo.com>2023-05-15 20:28:40 -0700
committerJoshua Cao <cao.joshua@yahoo.com>2023-05-15 20:31:24 -0700
commitfb7c237ca0dbc6f85c532f73e60616d0e7db82df (patch)
tree6f9e970c9c16097e19aee5aee8aa982c419b43a9 /llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
parent05cca8a1bc82aae1933c0e332a4d774cadc9f330 (diff)
downloadllvm-fb7c237ca0dbc6f85c532f73e60616d0e7db82df.zip
llvm-fb7c237ca0dbc6f85c532f73e60616d0e7db82df.tar.gz
llvm-fb7c237ca0dbc6f85c532f73e60616d0e7db82df.tar.bz2
[SimpleLoopUnswitch] Skip trivial select conds for selects
Fixes https://github.com/llvm/llvm-project/issues/62715 If a select's condition is a trivial select: ``` %s = select %cond, i1 true, i1 false ``` Unswitch on %cond, rather than %s. This fixes crashes where there is a disparity in finding candidates and and the transformation logic.
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index e15ee81..b3ebfaa 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -2872,7 +2872,7 @@ static bool collectUnswitchCandidates(
for (auto &I : *BB) {
if (auto *SI = dyn_cast<SelectInst>(&I)) {
- auto *Cond = SI->getCondition();
+ auto *Cond = skipTrivialSelect(SI->getCondition());
// restrict to simple boolean selects
if (!isa<Constant>(Cond) && L.isLoopInvariant(Cond) && Cond->getType()->isIntegerTy(1))
UnswitchCandidates.push_back({&I, {Cond}});