longbranch.ll
11.8 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; Except for the NACL version which isn't parsed by update_llc_test_checks.py
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O3 -relocation-model=pic < %s \
; RUN: | FileCheck %s -check-prefix=NOLONGBRANCH
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -force-mips-long-branch -O3 -relocation-model=pic < %s \
; RUN: | FileCheck %s -check-prefix=O32-PIC
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -force-mips-long-branch -O3 -relocation-model=static < %s \
; RUN: | FileCheck %s -check-prefix=O32-STATIC
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r6 -force-mips-long-branch -O3 \
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=O32-R6-PIC
; RUN: llc -mtriple=mips64el-unknown-linux-gnu -mcpu=mips4 -target-abi=n64 -force-mips-long-branch -O3 -relocation-model=pic \
; RUN: < %s | FileCheck %s -check-prefix=MIPS4
; RUN: llc -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64 -target-abi=n64 -force-mips-long-branch -O3 -relocation-model=pic \
; RUN: < %s | FileCheck %s -check-prefix=MIPS64
; RUN: llc -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64r6 -target-abi=n64 -force-mips-long-branch -O3 \
; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=N64-R6
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r2 -mattr=micromips \
; RUN: -force-mips-long-branch -O3 -relocation-model=pic < %s | FileCheck %s -check-prefix=MICROMIPS
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r2 -mattr=micromips \
; RUN: -force-mips-long-branch -O3 -relocation-model=static < %s | FileCheck %s -check-prefix=MICROMIPSSTATIC
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r6 -mattr=micromips \
; RUN: -force-mips-long-branch -O3 -relocation-model=static < %s | FileCheck %s -check-prefix=MICROMIPSR6STATIC
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r6 -mattr=micromips \
; RUN: -force-mips-long-branch -O3 -relocation-model=pic < %s | FileCheck %s -check-prefix=MICROMIPSR6PIC
; RUN: llc -mtriple=mipsel-none-nacl -force-mips-long-branch -O3 -relocation-model=pic < %s \
; RUN: | FileCheck %s -check-prefix=NACL
@x = external global i32
define void @test1(i32 signext %s) {
; NOLONGBRANCH-LABEL: test1:
; NOLONGBRANCH: # %bb.0: # %entry
; NOLONGBRANCH-NEXT: lui $2, %hi(_gp_disp)
; NOLONGBRANCH-NEXT: addiu $2, $2, %lo(_gp_disp)
; NOLONGBRANCH-NEXT: beqz $4, $BB0_2
; NOLONGBRANCH-NEXT: addu $2, $2, $25
; NOLONGBRANCH-NEXT: # %bb.1: # %then
; NOLONGBRANCH-NEXT: lw $1, %got(x)($2)
; NOLONGBRANCH-NEXT: addiu $2, $zero, 1
; NOLONGBRANCH-NEXT: sw $2, 0($1)
; NOLONGBRANCH-NEXT: $BB0_2: # %end
; NOLONGBRANCH-NEXT: jr $ra
; NOLONGBRANCH-NEXT: nop
;
; O32-PIC-LABEL: test1:
; O32-PIC: # %bb.0: # %entry
; O32-PIC-NEXT: lui $2, %hi(_gp_disp)
; O32-PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
; O32-PIC-NEXT: bnez $4, $BB0_3
; O32-PIC-NEXT: addu $2, $2, $25
; O32-PIC-NEXT: # %bb.1: # %entry
; O32-PIC-NEXT: addiu $sp, $sp, -8
; O32-PIC-NEXT: sw $ra, 0($sp)
; O32-PIC-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; O32-PIC-NEXT: bal $BB0_2
; O32-PIC-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; O32-PIC-NEXT: $BB0_2: # %entry
; O32-PIC-NEXT: addu $1, $ra, $1
; O32-PIC-NEXT: lw $ra, 0($sp)
; O32-PIC-NEXT: jr $1
; O32-PIC-NEXT: addiu $sp, $sp, 8
; O32-PIC-NEXT: $BB0_3: # %then
; O32-PIC-NEXT: lw $1, %got(x)($2)
; O32-PIC-NEXT: addiu $2, $zero, 1
; O32-PIC-NEXT: sw $2, 0($1)
; O32-PIC-NEXT: $BB0_4: # %end
; O32-PIC-NEXT: jr $ra
; O32-PIC-NEXT: nop
;
; O32-STATIC-LABEL: test1:
; O32-STATIC: # %bb.0: # %entry
; O32-STATIC-NEXT: bnez $4, $BB0_2
; O32-STATIC-NEXT: nop
; O32-STATIC-NEXT: # %bb.1: # %entry
; O32-STATIC-NEXT: j $BB0_3
; O32-STATIC-NEXT: nop
; O32-STATIC-NEXT: $BB0_2: # %then
; O32-STATIC-NEXT: lui $1, %hi(x)
; O32-STATIC-NEXT: addiu $2, $zero, 1
; O32-STATIC-NEXT: sw $2, %lo(x)($1)
; O32-STATIC-NEXT: $BB0_3: # %end
; O32-STATIC-NEXT: jr $ra
; O32-STATIC-NEXT: nop
;
; O32-R6-PIC-LABEL: test1:
; O32-R6-PIC: # %bb.0: # %entry
; O32-R6-PIC-NEXT: lui $2, %hi(_gp_disp)
; O32-R6-PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
; O32-R6-PIC-NEXT: bnez $4, $BB0_3
; O32-R6-PIC-NEXT: addu $2, $2, $25
; O32-R6-PIC-NEXT: # %bb.1: # %entry
; O32-R6-PIC-NEXT: addiu $sp, $sp, -8
; O32-R6-PIC-NEXT: sw $ra, 0($sp)
; O32-R6-PIC-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; O32-R6-PIC-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; O32-R6-PIC-NEXT: balc $BB0_2
; O32-R6-PIC-NEXT: $BB0_2: # %entry
; O32-R6-PIC-NEXT: addu $1, $ra, $1
; O32-R6-PIC-NEXT: lw $ra, 0($sp)
; O32-R6-PIC-NEXT: addiu $sp, $sp, 8
; O32-R6-PIC-NEXT: jrc $1
; O32-R6-PIC-NEXT: $BB0_3: # %then
; O32-R6-PIC-NEXT: lw $1, %got(x)($2)
; O32-R6-PIC-NEXT: addiu $2, $zero, 1
; O32-R6-PIC-NEXT: sw $2, 0($1)
; O32-R6-PIC-NEXT: $BB0_4: # %end
; O32-R6-PIC-NEXT: jrc $ra
;
; O32-R6-STATIC-LABEL: test1:
; O32-R6-STATIC: # %bb.0: # %entry
; O32-R6-STATIC-NEXT: bnezc $4, $BB0_2
; O32-R6-STATIC-NEXT: nop
; O32-R6-STATIC-NEXT: # %bb.1: # %entry
; O32-R6-STATIC-NEXT: bc $BB0_3
; O32-R6-STATIC-NEXT: $BB0_2: # %then
; O32-R6-STATIC-NEXT: lui $1, %hi(x)
; O32-R6-STATIC-NEXT: addiu $2, $zero, 1
; O32-R6-STATIC-NEXT: sw $2, %lo(x)($1)
; O32-R6-STATIC-NEXT: $BB0_3: # %end
; O32-R6-STATIC-NEXT: jrc $ra
;
; MIPS4-LABEL: test1:
; MIPS4: # %bb.0: # %entry
; MIPS4-NEXT: lui $1, %hi(%neg(%gp_rel(test1)))
; MIPS4-NEXT: bnez $4, .LBB0_3
; MIPS4-NEXT: daddu $2, $1, $25
; MIPS4-NEXT: # %bb.1: # %entry
; MIPS4-NEXT: daddiu $sp, $sp, -16
; MIPS4-NEXT: sd $ra, 0($sp)
; MIPS4-NEXT: daddiu $1, $zero, %hi(.LBB0_4-.LBB0_2)
; MIPS4-NEXT: dsll $1, $1, 16
; MIPS4-NEXT: bal .LBB0_2
; MIPS4-NEXT: daddiu $1, $1, %lo(.LBB0_4-.LBB0_2)
; MIPS4-NEXT: .LBB0_2: # %entry
; MIPS4-NEXT: daddu $1, $ra, $1
; MIPS4-NEXT: ld $ra, 0($sp)
; MIPS4-NEXT: jr $1
; MIPS4-NEXT: daddiu $sp, $sp, 16
; MIPS4-NEXT: .LBB0_3: # %then
; MIPS4-NEXT: daddiu $1, $2, %lo(%neg(%gp_rel(test1)))
; MIPS4-NEXT: addiu $2, $zero, 1
; MIPS4-NEXT: ld $1, %got_disp(x)($1)
; MIPS4-NEXT: sw $2, 0($1)
; MIPS4-NEXT: .LBB0_4: # %end
; MIPS4-NEXT: jr $ra
; MIPS4-NEXT: nop
;
; MIPS64-LABEL: test1:
; MIPS64: # %bb.0: # %entry
; MIPS64-NEXT: lui $1, %hi(%neg(%gp_rel(test1)))
; MIPS64-NEXT: bnez $4, .LBB0_3
; MIPS64-NEXT: daddu $2, $1, $25
; MIPS64-NEXT: # %bb.1: # %entry
; MIPS64-NEXT: daddiu $sp, $sp, -16
; MIPS64-NEXT: sd $ra, 0($sp)
; MIPS64-NEXT: daddiu $1, $zero, %hi(.LBB0_4-.LBB0_2)
; MIPS64-NEXT: dsll $1, $1, 16
; MIPS64-NEXT: bal .LBB0_2
; MIPS64-NEXT: daddiu $1, $1, %lo(.LBB0_4-.LBB0_2)
; MIPS64-NEXT: .LBB0_2: # %entry
; MIPS64-NEXT: daddu $1, $ra, $1
; MIPS64-NEXT: ld $ra, 0($sp)
; MIPS64-NEXT: jr $1
; MIPS64-NEXT: daddiu $sp, $sp, 16
; MIPS64-NEXT: .LBB0_3: # %then
; MIPS64-NEXT: daddiu $1, $2, %lo(%neg(%gp_rel(test1)))
; MIPS64-NEXT: addiu $2, $zero, 1
; MIPS64-NEXT: ld $1, %got_disp(x)($1)
; MIPS64-NEXT: sw $2, 0($1)
; MIPS64-NEXT: .LBB0_4: # %end
; MIPS64-NEXT: jr $ra
; MIPS64-NEXT: nop
;
; N64-R6-LABEL: test1:
; N64-R6: # %bb.0: # %entry
; N64-R6-NEXT: lui $1, %hi(%neg(%gp_rel(test1)))
; N64-R6-NEXT: bnez $4, .LBB0_3
; N64-R6-NEXT: daddu $2, $1, $25
; N64-R6-NEXT: # %bb.1: # %entry
; N64-R6-NEXT: daddiu $sp, $sp, -16
; N64-R6-NEXT: sd $ra, 0($sp)
; N64-R6-NEXT: daddiu $1, $zero, %hi(.LBB0_4-.LBB0_2)
; N64-R6-NEXT: dsll $1, $1, 16
; N64-R6-NEXT: daddiu $1, $1, %lo(.LBB0_4-.LBB0_2)
; N64-R6-NEXT: balc .LBB0_2
; N64-R6-NEXT: .LBB0_2: # %entry
; N64-R6-NEXT: daddu $1, $ra, $1
; N64-R6-NEXT: ld $ra, 0($sp)
; N64-R6-NEXT: daddiu $sp, $sp, 16
; N64-R6-NEXT: jrc $1
; N64-R6-NEXT: .LBB0_3: # %then
; N64-R6-NEXT: daddiu $1, $2, %lo(%neg(%gp_rel(test1)))
; N64-R6-NEXT: addiu $2, $zero, 1
; N64-R6-NEXT: ld $1, %got_disp(x)($1)
; N64-R6-NEXT: sw $2, 0($1)
; N64-R6-NEXT: .LBB0_4: # %end
; N64-R6-NEXT: jrc $ra
;
; MICROMIPS-LABEL: test1:
; MICROMIPS: # %bb.0: # %entry
; MICROMIPS-NEXT: lui $2, %hi(_gp_disp)
; MICROMIPS-NEXT: addiu $2, $2, %lo(_gp_disp)
; MICROMIPS-NEXT: bnez $4, $BB0_3
; MICROMIPS-NEXT: addu $2, $2, $25
; MICROMIPS-NEXT: # %bb.1: # %entry
; MICROMIPS-NEXT: addiu $sp, $sp, -8
; MICROMIPS-NEXT: sw $ra, 0($sp)
; MICROMIPS-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; MICROMIPS-NEXT: bal $BB0_2
; MICROMIPS-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; MICROMIPS-NEXT: $BB0_2: # %entry
; MICROMIPS-NEXT: addu $1, $ra, $1
; MICROMIPS-NEXT: lw $ra, 0($sp)
; MICROMIPS-NEXT: jr $1
; MICROMIPS-NEXT: addiu $sp, $sp, 8
; MICROMIPS-NEXT: $BB0_3: # %then
; MICROMIPS-NEXT: lw $2, %got(x)($2)
; MICROMIPS-NEXT: li16 $3, 1
; MICROMIPS-NEXT: sw16 $3, 0($2)
; MICROMIPS-NEXT: $BB0_4: # %end
; MICROMIPS-NEXT: jrc $ra
;
; MICROMIPSSTATIC-LABEL: test1:
; MICROMIPSSTATIC: # %bb.0: # %entry
; MICROMIPSSTATIC-NEXT: bnezc $4, $BB0_2
; MICROMIPSSTATIC-NEXT: # %bb.1: # %entry
; MICROMIPSSTATIC-NEXT: j $BB0_3
; MICROMIPSSTATIC-NEXT: nop
; MICROMIPSSTATIC-NEXT: $BB0_2: # %then
; MICROMIPSSTATIC-NEXT: lui $1, %hi(x)
; MICROMIPSSTATIC-NEXT: li16 $2, 1
; MICROMIPSSTATIC-NEXT: sw $2, %lo(x)($1)
; MICROMIPSSTATIC-NEXT: $BB0_3: # %end
; MICROMIPSSTATIC-NEXT: jrc $ra
;
; MICROMIPSR6STATIC-LABEL: test1:
; MICROMIPSR6STATIC: # %bb.0: # %entry
; MICROMIPSR6STATIC-NEXT: bnezc $4, $BB0_2
; MICROMIPSR6STATIC-NEXT: # %bb.1: # %entry
; MICROMIPSR6STATIC-NEXT: bc $BB0_3
; MICROMIPSR6STATIC-NEXT: $BB0_2: # %then
; MICROMIPSR6STATIC-NEXT: lui $1, %hi(x)
; MICROMIPSR6STATIC-NEXT: li16 $2, 1
; MICROMIPSR6STATIC-NEXT: sw $2, %lo(x)($1)
; MICROMIPSR6STATIC-NEXT: $BB0_3: # %end
; MICROMIPSR6STATIC-NEXT: jrc $ra
;
; MICROMIPSR6PIC-LABEL: test1:
; MICROMIPSR6PIC: # %bb.0: # %entry
; MICROMIPSR6PIC-NEXT: lui $2, %hi(_gp_disp)
; MICROMIPSR6PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
; MICROMIPSR6PIC-NEXT: addu $2, $2, $25
; MICROMIPSR6PIC-NEXT: bnezc $4, $BB0_3
; MICROMIPSR6PIC-NEXT: # %bb.1: # %entry
; MICROMIPSR6PIC-NEXT: addiu $sp, $sp, -8
; MICROMIPSR6PIC-NEXT: sw $ra, 0($sp)
; MICROMIPSR6PIC-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; MICROMIPSR6PIC-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; MICROMIPSR6PIC-NEXT: balc $BB0_2
; MICROMIPSR6PIC-NEXT: $BB0_2: # %entry
; MICROMIPSR6PIC-NEXT: addu $1, $ra, $1
; MICROMIPSR6PIC-NEXT: lw $ra, 0($sp)
; MICROMIPSR6PIC-NEXT: addiu $sp, $sp, 8
; MICROMIPSR6PIC-NEXT: jic $1, 0
; MICROMIPSR6PIC-NEXT: $BB0_3: # %then
; MICROMIPSR6PIC-NEXT: lw $2, %got(x)($2)
; MICROMIPSR6PIC-NEXT: li16 $3, 1
; MICROMIPSR6PIC-NEXT: sw16 $3, 0($2)
; MICROMIPSR6PIC-NEXT: $BB0_4: # %end
; MICROMIPSR6PIC-NEXT: jrc $ra
; NACL-LABEL: test1:
; NACL: # %bb.0:
; NACL-NEXT: lui $2, %hi(_gp_disp)
; NACL-NEXT: addiu $2, $2, %lo(_gp_disp)
; NACL-NEXT: bnez $4, $BB0_3
; NACL-NEXT: addu $2, $2, $25
; NACL-NEXT: # %bb.1:
; NACL-NEXT: addiu $sp, $sp, -8
; NACL-NEXT: sw $ra, 0($sp)
; NACL-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; NACL-NEXT: bal $BB0_2
; NACL-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; NACL-NEXT: $BB0_2:
; NACL-NEXT: addu $1, $ra, $1
; NACL-NEXT: lw $ra, 0($sp)
; NACL-NEXT: addiu $sp, $sp, 8
; NACL-NEXT: jr $1
; NACL-NEXT: nop
; NACL-NEXT: $BB0_3:
; NACL-NEXT: lw $1, %got(x)($2)
; NACL-NEXT: addiu $2, $zero, 1
; NACL-NEXT: sw $2, 0($1)
; NACL-NEXT: .p2align 4
; NACL-NEXT: $BB0_4:
; NACL-NEXT: jr $ra
; NACL-NEXT: nop
; Check the NaCl version. Check that sp change is not in the branch delay slot
; of "jr $1" instruction. Check that target of indirect branch "jr $1" is
; bundle aligned.
entry:
%cmp = icmp eq i32 %s, 0
br i1 %cmp, label %end, label %then
then:
store i32 1, i32* @x, align 4
br label %end
end:
ret void
}