Fix broken testcase from r242358.
[oota-llvm.git] / test / CodeGen / MIR / X86 / jump-table-info.mir
1 # RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
2 # This test ensures that the MIR parser parses the jump table info and jump
3 # table operands correctly.
4
5 --- |
6
7   define i32 @test_jumptable(i32 %in) {
8   entry:
9     switch i32 %in, label %def [
10       i32 0, label %lbl1
11       i32 1, label %lbl2
12       i32 2, label %lbl3
13       i32 3, label %lbl4
14     ]
15
16   def:
17     ret i32 0
18
19   lbl1:
20     ret i32 1
21
22   lbl2:
23     ret i32 2
24
25   lbl3:
26     ret i32 4
27
28   lbl4:
29     ret i32 8
30   }
31
32   define i32 @test_jumptable2(i32 %in) {
33   entry:
34     switch i32 %in, label %def [
35       i32 0, label %lbl1
36       i32 1, label %lbl2
37       i32 2, label %lbl3
38       i32 3, label %lbl4
39     ]
40
41   def:
42     ret i32 0
43
44   lbl1:
45     ret i32 1
46
47   lbl2:
48     ret i32 2
49
50   lbl3:
51     ret i32 4
52
53   lbl4:
54     ret i32 8
55   }
56
57 ...
58 ---
59 name:            test_jumptable
60 # CHECK:      jumpTable:
61 # CHECK-NEXT: kind: label-difference32
62 # CHECK-NEXT: entries:
63 # CHECK-NEXT: - id: 0
64 # CHECK-NEXT: blocks: [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
65 # CHECK_NEXT: body:
66 jumpTable:
67   kind:          label-difference32
68   entries:
69     - id:        0
70       blocks:    [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
71 body:
72   - id:          0
73     name:        entry
74     successors:  [ '%bb.2.def', '%bb.1.entry' ]
75     instructions:
76       - '%eax = MOV32rr %edi, implicit-def %rax'
77       - 'CMP32ri8 %edi, 3, implicit-def %eflags'
78       - 'JA_1 %bb.2.def, implicit %eflags'
79   - id:          1
80     name:        entry
81     successors:  [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
82     instructions:
83     # CHECK: %rcx = LEA64r %rip, 1, _, %jump-table.0, _
84       - '%rcx = LEA64r %rip, 1, _, %jump-table.0, _'
85       - '%rax = MOVSX64rm32 %rcx, 4, %rax, 0, _'
86       - '%rax = ADD64rr %rax, %rcx, implicit-def %eflags'
87       - 'JMP64r %rax'
88   - id:          2
89     name:        def
90     instructions:
91       - '%eax = MOV32r0 implicit-def %eflags'
92       - 'RETQ %eax'
93   - id:          3
94     name:        lbl1
95     instructions:
96       - '%eax = MOV32ri 1'
97       - 'RETQ %eax'
98   - id:          4
99     name:        lbl2
100     instructions:
101       - '%eax = MOV32ri 2'
102       - 'RETQ %eax'
103   - id:          5
104     name:        lbl3
105     instructions:
106       - '%eax = MOV32ri 4'
107       - 'RETQ %eax'
108   - id:          6
109     name:        lbl4
110     instructions:
111       - '%eax = MOV32ri 8'
112       - 'RETQ %eax'
113 ...
114 ---
115 name:            test_jumptable2
116 jumpTable:
117   kind:          label-difference32
118   entries:
119     - id:        1
120       blocks:    [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
121 body:
122   - id:          0
123     name:        entry
124     successors:  [ '%bb.2.def', '%bb.1.entry' ]
125     instructions:
126       - '%eax = MOV32rr %edi, implicit-def %rax'
127       - 'CMP32ri8 %edi, 3, implicit-def %eflags'
128       - 'JA_1 %bb.2.def, implicit %eflags'
129   - id:          1
130     name:        entry
131     successors:  [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
132     instructions:
133     # Verify that the printer will use an id of 0 for this jump table:
134     # CHECK: %rcx = LEA64r %rip, 1, _, %jump-table.0, _
135       - '%rcx = LEA64r %rip, 1, _, %jump-table.1, _'
136       - '%rax = MOVSX64rm32 %rcx, 4, %rax, 0, _'
137       - '%rax = ADD64rr %rax, %rcx, implicit-def %eflags'
138       - 'JMP64r %rax'
139   - id:         2
140     name:       def
141     instructions:
142       - '%eax = MOV32r0 implicit-def %eflags'
143       - 'RETQ %eax'
144   - id:         3
145     name:       lbl1
146     instructions:
147       - '%eax = MOV32ri 1'
148       - 'RETQ %eax'
149   - id:         4
150     name:       lbl2
151     instructions:
152       - '%eax = MOV32ri 2'
153       - 'RETQ %eax'
154   - id:         5
155     name:       lbl3
156     instructions:
157       - '%eax = MOV32ri 4'
158       - 'RETQ %eax'
159   - id:         6
160     name:       lbl4
161     instructions:
162       - '%eax = MOV32ri 8'
163       - 'RETQ %eax'
164 ...