[llvm] r365611 - [SimpleLoopUnswitch] Don't consider unswitching `switch` insructions with one unique successor
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 03:25:22 PDT 2019
Author: skatkov
Date: Wed Jul 10 03:25:22 2019
New Revision: 365611
URL: http://llvm.org/viewvc/llvm-project?rev=365611&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp?rev=365611&r1=365610&r2=365611&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp Wed Jul 10 03:25:22 2019
@@ -2552,7 +2552,7 @@ unswitchBestCondition(Loop &L, Dominator
// We can only consider fully loop-invariant switch conditions as we need
// to completely eliminate the switch after unswitching.
if (!isa<Constant>(SI->getCondition()) &&
- L.isLoopInvariant(SI->getCondition()))
+ L.isLoopInvariant(SI->getCondition()) && !BB->getUniqueSuccessor())
UnswitchCandidates.push_back({SI, {SI->getCondition()}});
continue;
}
Modified: llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll?rev=365611&r1=365610&r2=365611&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll (original)
+++ llvm/trunk/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-redundant-switch.ll Wed Jul 10 03:25:22 2019
@@ -1,5 +1,4 @@
; REQUIRES: asserts
-; XFAIL: *
; RUN: opt -passes='unswitch<nontrivial>' -disable-output -S < %s
; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output -S < %s
More information about the llvm-commits
mailing list