• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -simplifycfg < %s | FileCheck %s
2
3; We're sign extending an 8-bit value.
4; The switch condition must be in the range [-128, 127], so any cases outside of that range must be dead.
5; Only the first case has a non-zero weight, but that gets eliminated. Note
6; that this shouldn't have been the case in the first place, but the test here
7; ensures that all-zero branch weights are not attached causing problems downstream.
8
9define i1 @repeated_signbits(i8 %condition) {
10; CHECK-LABEL: @repeated_signbits(
11; CHECK:         switch i32
12; CHECK-DAG:     i32 -128, label %a
13; CHECK-DAG:     i32 -1, label %a
14; CHECK-DAG:     i32  0, label %a
15; CHECK-DAG:     i32  127, label %a
16; CHECK-NEXT:    ]
17; CHECK-NOT:    , !prof
18;
19entry:
20  %sext = sext i8 %condition to i32
21  switch i32 %sext, label %default [
22  i32 -2147483648, label %a
23  i32 -129, label %a
24  i32 -128, label %a
25  i32 -1, label %a
26  i32  0, label %a
27  i32  127, label %a
28  i32  128, label %a
29  i32  2147483647, label %a
30  ], !prof !1
31
32a:
33  ret i1 1
34
35default:
36  ret i1 0
37}
38
39!1 = !{!"branch_weights", i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0}
40
41