Index: llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2552,7 +2552,7 @@ // We can only consider fully loop-invariant switch conditions as we need // to completely eliminate the switch after unswitching. if (!isa(SI->getCondition()) && - L.isLoopInvariant(SI->getCondition())) + L.isLoopInvariant(SI->getCondition()) && !BB->getUniqueSuccessor()) UnswitchCandidates.push_back({SI, {SI->getCondition()}}); continue; } Index: llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll =================================================================== --- llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll +++ llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll @@ -1,5 +1,4 @@ ; REQUIRES: asserts -; XFAIL: * ; RUN: opt -passes='unswitch' -disable-output -S < %s ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output -S < %s