Skip to content

Commit af9be74

Browse files
authored
Revert "[SimplifyCFG] switch: Do Not Transform the Default Case if the Condition is Too Wide"
1 parent 5ddd7bc commit af9be74

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,11 +5623,6 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, DomTreeUpdater *DTU,
56235623
// optimization, such as lookup tables.
56245624
if (SI->getNumCases() == AllNumCases - 1) {
56255625
assert(NumUnknownBits > 1 && "Should be canonicalized to a branch");
5626-
IntegerType *CondTy = cast<IntegerType>(Cond->getType());
5627-
if (CondTy->getIntegerBitWidth() > 64 ||
5628-
!DL.fitsInLegalInteger(CondTy->getIntegerBitWidth()))
5629-
return false;
5630-
56315626
uint64_t MissingCaseVal = 0;
56325627
for (const auto &Case : SI->cases())
56335628
MissingCaseVal ^= Case.getCaseValue()->getValue().getLimitedValue();

llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,39 +313,6 @@ default:
313313

314314
declare void @llvm.assume(i1)
315315

316-
define zeroext i1 @test8(i128 %a) {
317-
; We should not transform conditions wider than 64 bit.
318-
; CHECK-LABEL: define zeroext i1 @test8(
319-
; CHECK-SAME: i128 [[A:%.*]]) {
320-
; CHECK-NEXT: entry:
321-
; CHECK-NEXT: [[TMP0:%.*]] = and i128 [[A]], 3894222643901120721397872246915072
322-
; CHECK-NEXT: switch i128 [[TMP0]], label [[LOR_RHS:%.*]] [
323-
; CHECK-NEXT: i128 1298074214633706907132624082305024, label [[LOR_END:%.*]]
324-
; CHECK-NEXT: i128 2596148429267413814265248164610048, label [[LOR_END]]
325-
; CHECK-NEXT: i128 3894222643901120721397872246915072, label [[LOR_END]]
326-
; CHECK-NEXT: ]
327-
; CHECK: lor.rhs:
328-
; CHECK-NEXT: br label [[LOR_END]]
329-
; CHECK: lor.end:
330-
; CHECK-NEXT: [[TMP1:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ false, [[LOR_RHS]] ], [ true, [[ENTRY]] ], [ true, [[ENTRY]] ]
331-
; CHECK-NEXT: ret i1 [[TMP1]]
332-
;
333-
entry:
334-
%0 = and i128 %a, 3894222643901120721397872246915072
335-
switch i128 %0, label %lor.rhs [
336-
i128 1298074214633706907132624082305024, label %lor.end
337-
i128 2596148429267413814265248164610048, label %lor.end
338-
i128 3894222643901120721397872246915072, label %lor.end
339-
]
340-
341-
lor.rhs: ; preds = %entry
342-
br label %lor.end
343-
344-
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
345-
%1 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
346-
ret i1 %1
347-
}
348-
349316
!0 = !{!"branch_weights", i32 8, i32 4, i32 2, i32 1}
350317
;.
351318
; CHECK: [[PROF0]] = !{!"branch_weights", i32 0, i32 4, i32 2, i32 1, i32 8}

0 commit comments

Comments
 (0)