From d000f8b69f721c8d9bfcf90dd8df9a25bbf3b2e5 Mon Sep 17 00:00:00 2001 From: Serguei Katkov Date: Wed, 10 Jul 2019 10:25:22 +0000 Subject: [SimpleLoopUnswitch] Don't consider unswitching `switch` insructions with one unique successor Only instructions with two or more unique successors should be considered for unswitching. Patch Author: Daniil Suchkov. Reviewers: reames, asbirlea, skatkov Reviewed By: skatkov Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D64404 llvm-svn: 365611 --- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp') diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 82e98ec1877..97153292238 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2552,7 +2552,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI, // 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; } -- cgit v1.2.3