Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp =================================================================== --- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -1518,7 +1518,9 @@ if (LI) { if (Loop *L = LI->getLoopFor(Head)) { - L->addBasicBlockToLoop(ThenBlock, *LI); + // unreachable-terminated blocks cannot belong to any loop. + if (!Unreachable) + L->addBasicBlockToLoop(ThenBlock, *LI); L->addBasicBlockToLoop(Tail, *LI); } } Index: llvm/test/Transforms/SimpleLoopUnswitch/guards.ll =================================================================== --- llvm/test/Transforms/SimpleLoopUnswitch/guards.ll +++ llvm/test/Transforms/SimpleLoopUnswitch/guards.ll @@ -2,9 +2,6 @@ ; RUN: opt -passes='simple-loop-unswitch' -simple-loop-unswitch-guards -S < %s | FileCheck %s ; RUN: opt -passes='loop-mssa(simple-loop-unswitch),verify' -simple-loop-unswitch-guards -verify-memoryssa -S < %s | FileCheck %s -; XFAIL: * -; REQUIRES: asserts - declare void @llvm.experimental.guard(i1, ...) define void @test_simple_case(i1 %cond, i32 %N) { Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll =================================================================== --- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll +++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll @@ -7,9 +7,6 @@ declare void @llvm.experimental.guard(i1, ...) declare void @widget() -; XFAIL: * -; REQUIRES: asserts - define void @foo(ptr addrspace(1) %arg, i64 %arg1) personality ptr @pluto { ; CHECK-LABEL: @foo( ; CHECK-NEXT: bb: