1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
4 ; We're sign extending an 8-bit value.
5 ; The switch condition must be in the range [-128, 127], so any cases outside of that range must be dead.
6 ; Only the first case has a non-zero weight, but that gets eliminated. Note
7 ; that this shouldn't have been the case in the first place, but the test here
8 ; ensures that all-zero branch weights are not attached causing problems downstream.
10 define i1 @repeated_signbits(i8 %condition) {
11 ; CHECK-LABEL: @repeated_signbits(
13 ; CHECK-NEXT: [[SEXT:%.*]] = sext i8 [[CONDITION:%.*]] to i32
14 ; CHECK-NEXT: switch i32 [[SEXT]], label [[DEFAULT:%.*]] [
15 ; CHECK-NEXT: i32 0, label [[COMMON_RET:%.*]]
16 ; CHECK-NEXT: i32 127, label [[COMMON_RET]]
17 ; CHECK-NEXT: i32 -128, label [[COMMON_RET]]
18 ; CHECK-NEXT: i32 -1, label [[COMMON_RET]]
21 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i1 [ false, [[DEFAULT]] ], [ true, [[ENTRY:%.*]] ], [ true, [[ENTRY]] ], [ true, [[ENTRY]] ], [ true, [[ENTRY]] ]
22 ; CHECK-NEXT: ret i1 [[COMMON_RET_OP]]
24 ; CHECK-NEXT: br label [[COMMON_RET]]
27 %sext = sext i8 %condition to i32
28 switch i32 %sext, label %default [
29 i32 -2147483648, label %a
36 i32 2147483647, label %a
46 !1 = !{!"branch_weights", i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0}