Skip to content

Commit 41c4da0

Browse files
committed
[SimplifyCFG] Cases to the default destination cannot be contiguous cases
1 parent c56155d commit 41c4da0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5838,7 +5838,8 @@ bool SimplifyCFGOpt::turnSwitchRangeIntoICmp(SwitchInst *SI,
58385838
bool IsWrapping = false;
58395839
SmallVectorImpl<ConstantInt *> *ContiguousCases = &CasesA;
58405840
SmallVectorImpl<ConstantInt *> *OtherCases = &CasesB;
5841-
if (!CasesA.empty() &&
5841+
// Correctness: Cases to the default destination cannot be contiguous cases.
5842+
if (!HasDefault && !CasesA.empty() &&
58425843
casesAreContiguous(SI->getCondition(), CasesA, ContiguousCasesMin,
58435844
ContiguousCasesMax, IsWrapping)) {
58445845
ContiguousDest = DestA;

0 commit comments

Comments
 (0)