1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-- -run-pass=machine-sink -verify-machineinstrs -o - %s | FileCheck %s
6 tracksRegLiveness: true
11 blocks: [ '%bb.4', '%bb.1', '%bb.2', '%bb.3' ]
13 ; CHECK-LABEL: name: func_no_pic
15 ; CHECK-NEXT: successors: %bb.5(0x20000000), %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000)
16 ; CHECK-NEXT: liveins: $edi
18 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64_nosp = COPY $rdi
19 ; CHECK-NEXT: JMP64m $noreg, 8, [[COPY]], %jump-table.0, $noreg :: (load (s64) from jump-table)
22 ; CHECK-NEXT: successors: %bb.4(0x80000000)
24 ; CHECK-NEXT: [[MOV32ri:%[0-9]+]]:gr32 = MOV32ri 42
25 ; CHECK-NEXT: JMP_1 %bb.4
28 ; CHECK-NEXT: successors: %bb.4(0x80000000)
30 ; CHECK-NEXT: [[MOV32ri1:%[0-9]+]]:gr32 = MOV32ri 6
31 ; CHECK-NEXT: JMP_1 %bb.4
34 ; CHECK-NEXT: successors: %bb.4(0x80000000)
36 ; CHECK-NEXT: [[MOV32ri2:%[0-9]+]]:gr32 = MOV32ri 1
37 ; CHECK-NEXT: JMP_1 %bb.4
40 ; CHECK-NEXT: successors: %bb.4(0x80000000)
42 ; CHECK-NEXT: [[MOV32ri3:%[0-9]+]]:gr32 = MOV32ri 92
43 ; CHECK-NEXT: JMP_1 %bb.4
46 ; CHECK-NEXT: [[PHI:%[0-9]+]]:gr32 = PHI [[MOV32ri]], %bb.5, [[MOV32ri1]], %bb.1, [[MOV32ri2]], %bb.2, [[MOV32ri3]], %bb.3
47 ; CHECK-NEXT: $eax = COPY [[PHI]]
50 successors: %bb.4, %bb.1, %bb.2, %bb.3
53 %0:gr64_nosp = COPY $rdi
54 ; MachineSink should split the critical edges and sink the next two
55 ; insns out of the switch-jump header into new less frequently executed
58 JMP64m $noreg, 8, %0, %jump-table.0, $noreg :: (load (s64) from jump-table)
73 %5:gr32 = PHI %1, %bb.0, %2, %bb.1, %3, %bb.2, %4, %bb.3
80 tracksRegLiveness: true
82 kind: label-difference32
85 blocks: [ '%bb.4', '%bb.1', '%bb.2', '%bb.3' ]
87 ; CHECK-LABEL: name: func_pic
89 ; CHECK-NEXT: successors: %bb.5(0x20000000), %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000)
90 ; CHECK-NEXT: liveins: $edi
92 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64_nosp = COPY $rdi
93 ; CHECK-NEXT: [[LEA64r:%[0-9]+]]:gr64 = LEA64r $rip, 1, $noreg, %jump-table.0, $noreg
94 ; CHECK-NEXT: [[MOVSX64rm32_:%[0-9]+]]:gr64 = MOVSX64rm32 [[LEA64r]], 4, [[COPY]], 0, $noreg :: (load (s32) from jump-table)
95 ; CHECK-NEXT: [[ADD64rr:%[0-9]+]]:gr64 = ADD64rr [[MOVSX64rm32_]], [[LEA64r]], implicit-def dead $eflags
96 ; CHECK-NEXT: JMP64r killed [[ADD64rr]]
99 ; CHECK-NEXT: successors: %bb.4(0x80000000)
101 ; CHECK-NEXT: [[MOV32ri:%[0-9]+]]:gr32 = MOV32ri 42
102 ; CHECK-NEXT: JMP_1 %bb.4
105 ; CHECK-NEXT: successors: %bb.4(0x80000000)
107 ; CHECK-NEXT: [[MOV32ri1:%[0-9]+]]:gr32 = MOV32ri 6
108 ; CHECK-NEXT: JMP_1 %bb.4
111 ; CHECK-NEXT: successors: %bb.4(0x80000000)
113 ; CHECK-NEXT: [[MOV32ri2:%[0-9]+]]:gr32 = MOV32ri 1
114 ; CHECK-NEXT: JMP_1 %bb.4
117 ; CHECK-NEXT: successors: %bb.4(0x80000000)
119 ; CHECK-NEXT: [[MOV32ri3:%[0-9]+]]:gr32 = MOV32ri 92
120 ; CHECK-NEXT: JMP_1 %bb.4
123 ; CHECK-NEXT: [[PHI:%[0-9]+]]:gr32 = PHI [[MOV32ri]], %bb.5, [[MOV32ri1]], %bb.1, [[MOV32ri2]], %bb.2, [[MOV32ri3]], %bb.3
124 ; CHECK-NEXT: $eax = COPY [[PHI]]
127 successors: %bb.4, %bb.1, %bb.2, %bb.3
130 %0:gr64_nosp = COPY $rdi
131 ; MachineSink should split the critical edges and sink the next two
132 ; insns out of the switch-jump header into new less frequently executed
135 %2:gr64 = LEA64r $rip, 1, $noreg, %jump-table.0, $noreg
136 %3:gr64 = MOVSX64rm32 %2, 4, %0, 0, $noreg :: (load (s32) from jump-table)
137 %4:gr64 = ADD64rr %3, %2, implicit-def dead $eflags
153 %8:gr32 = PHI %1, %bb.0, %5, %bb.1, %6, %bb.2, %7, %bb.3
159 name: multiple_jump_table_users
160 tracksRegLiveness: true
165 blocks: [ '%bb.6', '%bb.3', '%bb.4', '%bb.5' ]
167 ; CHECK-LABEL: name: multiple_jump_table_users
169 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
170 ; CHECK-NEXT: liveins: $edi
172 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64_nosp = COPY $rdi
173 ; CHECK-NEXT: CMP64ri8 [[COPY]], 42, implicit-def $eflags
174 ; CHECK-NEXT: JCC_1 %bb.1, 15, implicit $eflags
175 ; CHECK-NEXT: JMP_1 %bb.2
178 ; CHECK-NEXT: successors: %bb.6(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
180 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */
181 ; CHECK-NEXT: [[MOV32ri:%[0-9]+]]:gr32 = MOV32ri 13
182 ; CHECK-NEXT: JMP64m $noreg, 8, [[COPY]], %jump-table.0, $noreg :: (load (s64) from jump-table)
185 ; CHECK-NEXT: successors: %bb.6(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000), %bb.5(0x20000000)
187 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */
188 ; CHECK-NEXT: [[MOV32ri1:%[0-9]+]]:gr32 = MOV32ri 42
189 ; CHECK-NEXT: JMP64m $noreg, 8, [[COPY]], %jump-table.0, $noreg :: (load (s64) from jump-table)
192 ; CHECK-NEXT: successors: %bb.6(0x80000000)
194 ; CHECK-NEXT: [[MOV32ri2:%[0-9]+]]:gr32 = MOV32ri 6
195 ; CHECK-NEXT: JMP_1 %bb.6
198 ; CHECK-NEXT: successors: %bb.6(0x80000000)
200 ; CHECK-NEXT: [[MOV32ri3:%[0-9]+]]:gr32 = MOV32ri 1
201 ; CHECK-NEXT: JMP_1 %bb.6
204 ; CHECK-NEXT: successors: %bb.6(0x80000000)
206 ; CHECK-NEXT: [[MOV32ri4:%[0-9]+]]:gr32 = MOV32ri 92
207 ; CHECK-NEXT: JMP_1 %bb.6
210 ; CHECK-NEXT: [[PHI:%[0-9]+]]:gr32 = PHI [[MOV32ri]], %bb.1, [[MOV32ri1]], %bb.2, [[MOV32ri2]], %bb.3, [[MOV32ri3]], %bb.4, [[MOV32ri4]], %bb.5
211 ; CHECK-NEXT: $eax = COPY [[PHI]]
215 %0:gr64_nosp = COPY $rdi
217 CMP64ri8 %0:gr64_nosp, 42, implicit-def $eflags
218 JCC_1 %bb.1, 15, implicit $eflags
222 successors: %bb.6, %bb.3, %bb.4, %bb.5
223 INLINEASM &"", 1 /* sideeffect attdialect */
225 JMP64m $noreg, 8, %0, %jump-table.0, $noreg :: (load (s64) from jump-table)
228 successors: %bb.6, %bb.3, %bb.4, %bb.5
229 INLINEASM &"", 1 /* sideeffect attdialect */
231 ; This is a 2d user of jump-table.0 . This case is not supported yet;
232 ; Should not attempt edge splitting.
233 JMP64m $noreg, 8, %0, %jump-table.0, $noreg :: (load (s64) from jump-table)
248 %6:gr32 = PHI %1, %bb.1, %2, %bb.2, %3, %bb.3, %4, %bb.4, %5, %bb.5