Skip to content

Commit 3089b0b

Browse files
committed
Don't loop unswitch vector selects
Otherwise we could produce `br <2x i1>` which are of course not legal. ``` Branch condition is not 'i1' type! br <2 x i1> %cond.fr1, label %entry.split.us, label %entry.split %cond.fr1 = freeze <2 x i1> %cond LLVM ERROR: Broken module found, compilation aborted! PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /home/vchuravy/builds/llvm/bin/opt -passes=simple-loop-unswitch<nontrivial> -S ``` Fixes https://reviews.llvm.org/D138526 Differential Revision: https://reviews.llvm.org/D149560
1 parent fcc8566 commit 3089b0b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2810,7 +2810,8 @@ static bool unswitchBestCondition(
28102810
for (auto &I : *BB) {
28112811
if (auto *SI = dyn_cast<SelectInst>(&I)) {
28122812
auto *Cond = SI->getCondition();
2813-
if (!isa<Constant>(Cond) && L.isLoopInvariant(Cond))
2813+
// restrict to simple boolean selects
2814+
if (!isa<Constant>(Cond) && L.isLoopInvariant(Cond) && Cond->getType()->isIntegerTy(1))
28142815
UnswitchCandidates.push_back({&I, {Cond}});
28152816
} else if (CollectGuards && isGuard(&I)) {
28162817
auto *Cond =

0 commit comments

Comments
 (0)