summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll
blob: e0819bda254a64ca583f9cab4cf5b42b4683e6b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
; RUN: llc -O3 -o - %s | FileCheck %s

; Test that the output in the presence of an unreachable default does not have
; a compare and branch at the top of the switch to handle the default case.

target triple = "aarch64-unknown-linux-gnu"

; Function Attrs: nounwind
define void @fn(i4) {
  switch i4 %0, label %default [
    i4 0, label %case_0
    i4 1, label %case_1
    i4 2, label %case_2
    i4 3, label %case_3
    i4 4, label %case_4
    i4 5, label %case_5
  ]

; CHECK-LABEL: fn:
; CHECK-NOT:    sub
; CHECK-NOT:    cmp
; CHECK-NOT:    b.hi
; CHECK:        ldr {{x[0-9]+}}, [{{x[0-9]+}}, {{x[0-9]+}}, lsl #3]
; CHECK:        br {{x[0-9]+}}

default:
  unreachable

case_0:
  tail call void @handle_case_00(i4 %0) #2
  br label %return_label

case_1:
  tail call void @handle_case_01(i4 %0) #2
  br label %return_label

case_2:
  tail call void @handle_case_02(i4 %0) #2
  br label %return_label

case_3:
  tail call void @handle_case_03(i4 %0) #2
  br label %return_label

case_4:
  tail call void @handle_case_04(i4 %0) #2
  br label %return_label

case_5:
  tail call void @handle_case_05(i4 %0) #2
  br label %return_label

return_label:
  ret void
}

declare  void @handle_case_00(i4)
declare  void @handle_case_01(i4)
declare  void @handle_case_02(i4)
declare  void @handle_case_03(i4)
declare  void @handle_case_04(i4)
declare  void @handle_case_05(i4)
; RUN: llc -O3 -o - %s | FileCheck %s

; Test that the output in the presence of an unreachable default does not have
; a compare and branch at the top of the switch to handle the default case.

target triple = "aarch64-unknown-linux-gnu"

; Function Attrs: nounwind
define void @fn(i4) {
  switch i4 %0, label %default [
    i4 0, label %case_0
    i4 1, label %case_1
    i4 2, label %case_2
    i4 3, label %case_3
    i4 4, label %case_4
    i4 5, label %case_5
  ]

; CHECK-LABEL: fn:
; CHECK-NOT:    sub
; CHECK-NOT:    cmp
; CHECK-NOT:    b.hi
; CHECK:        ldr {{x[0-9]+}}, [{{x[0-9]+}}, {{x[0-9]+}}, lsl #3]
; CHECK:        br {{x[0-9]+}}

default:
  unreachable

case_0:
  tail call void @handle_case_00(i4 %0) #2
  br label %return_label

case_1:
  tail call void @handle_case_01(i4 %0) #2
  br label %return_label

case_2:
  tail call void @handle_case_02(i4 %0) #2
  br label %return_label

case_3:
  tail call void @handle_case_03(i4 %0) #2
  br label %return_label

case_4:
  tail call void @handle_case_04(i4 %0) #2
  br label %return_label

case_5:
  tail call void @handle_case_05(i4 %0) #2
  br label %return_label

return_label:
  ret void
}

declare  void @handle_case_00(i4)
declare  void @handle_case_01(i4)
declare  void @handle_case_02(i4)
declare  void @handle_case_03(i4)
declare  void @handle_case_04(i4)
declare  void @handle_case_05(i4)
OpenPOWER on IntegriCloud