• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=i686-pc-gnu-linux < %s | FileCheck %s
2
3
4; An unreachable default destination is replaced with the most popular case label.
5
6define void @sum2(i32 %x, i32* %to) {
7; CHECK-LABEL: sum2:
8; CHECK: movl 4(%esp), [[REG:%e[a-z]{2}]]
9; CHECK: cmpl $3, [[REG]]
10; CHECK: jbe .LBB0_1
11; CHECK: movl $4
12; CHECK: retl
13; CHECK-LABEL: .LBB0_1:
14; CHECK-NEXT: jmpl *.LJTI0_0(,[[REG]],4)
15
16entry:
17  switch i32 %x, label %default [
18    i32 0, label %bb0
19    i32 1, label %bb1
20    i32 2, label %bb2
21    i32 3, label %bb3
22    i32 4, label %bb4
23    i32 5, label %bb4
24  ]
25bb0:
26  store i32 0, i32* %to
27  br label %exit
28bb1:
29  store i32 1, i32* %to
30  br label %exit
31bb2:
32  store i32 2, i32* %to
33  br label %exit
34bb3:
35  store i32 3, i32* %to
36  br label %exit
37bb4:
38  store i32 4, i32* %to
39  br label %exit
40exit:
41  ret void
42default:
43  unreachable
44
45; The jump table has four entries.
46; CHECK-LABEL: .LJTI0_0:
47; CHECK-NEXT: .long  .LBB0_2
48; CHECK-NEXT: .long  .LBB0_3
49; CHECK-NEXT: .long  .LBB0_4
50; CHECK-NEXT: .long  .LBB0_5
51; CHECK-NOT: .long
52}
53