blob: 87fb248e56fdb48b25e0bd60d43c32bd6e85315d [file] [log] [blame]
Daniel Sanders0d972702016-06-24 12:23:17 +00001; RUN: llc -march=mipsel -mcpu=mips32 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS32R1
2; RUN: llc -march=mipsel -mcpu=mips32r2 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS32R2
3; RUN: llc -march=mipsel -mcpu=mips32r6 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS32R6
4; RUN: llc -march=mips64el -mcpu=mips4 -target-abi=n64 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS4
5; RUN: llc -march=mips64el -mcpu=mips64 -target-abi=n64 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS4
6; RUN: llc -march=mips64el -mcpu=mips64r2 -target-abi=n64 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS4
7; RUN: llc -march=mips64el -mcpu=mips64r6 -target-abi=n64 -relocation-model=pic < %s | FileCheck %s -check-prefixes=ALL,MIPS64R6
Daniel Sandersfd61fd32014-06-12 14:19:28 +00008
9; Check that [ls][dwu]xc1 are not emitted for nacl.
10; RUN: llc -mtriple=mipsel-none-nacl-gnu -mcpu=mips32r2 < %s | FileCheck %s -check-prefix=CHECK-NACL
Akira Hatanaka330d9012012-02-28 02:55:02 +000011
12%struct.S = type <{ [4 x float] }>
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +000013%struct.S2 = type <{ [4 x double] }>
14%struct.S3 = type <{ i8, float }>
Akira Hatanaka330d9012012-02-28 02:55:02 +000015
16@s = external global [4 x %struct.S]
17@gf = external global float
18@gd = external global double
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +000019@s2 = external global [4 x %struct.S2]
20@s3 = external global %struct.S3
Akira Hatanaka330d9012012-02-28 02:55:02 +000021
22define float @foo0(float* nocapture %b, i32 %o) nounwind readonly {
23entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +000024; ALL-LABEL: foo0:
25
26; MIPS32R1: sll $[[T1:[0-9]+]], $5, 2
27; MIPS32R1: addu $[[T3:[0-9]+]], $4, $[[T1]]
28; MIPS32R1: lwc1 $f0, 0($[[T3]])
29
30; MIPS32R2: sll $[[T1:[0-9]+]], $5, 2
31; MIPS32R2: lwxc1 $f0, $[[T1]]($4)
32
33; MIPS32R6: sll $[[T1:[0-9]+]], $5, 2
34; MIPS32R6: addu $[[T3:[0-9]+]], $4, $[[T1]]
35; MIPS32R6: lwc1 $f0, 0($[[T3]])
36
37; MIPS4: sll $[[T0:[0-9]+]], $5, 0
38; MIPS4: dsll $[[T1:[0-9]+]], $[[T0]], 2
39; MIPS4: lwxc1 $f0, $[[T1]]($4)
40
41; MIPS64R6: sll $[[T0:[0-9]+]], $5, 0
42; MIPS64R6: dsll $[[T1:[0-9]+]], $[[T0]], 2
43; MIPS64R6: daddu $[[T3:[0-9]+]], $4, $[[T1]]
44; MIPS64R6: lwc1 $f0, 0($[[T3]])
45
Petar Jovanovic97250162014-02-05 17:19:30 +000046; CHECK-NACL-NOT: lwxc1
Daniel Sandersfd61fd32014-06-12 14:19:28 +000047
David Blaikie79e6c742015-02-27 19:29:02 +000048 %arrayidx = getelementptr inbounds float, float* %b, i32 %o
David Blaikiea79ac142015-02-27 21:17:42 +000049 %0 = load float, float* %arrayidx, align 4
Akira Hatanaka330d9012012-02-28 02:55:02 +000050 ret float %0
51}
52
53define double @foo1(double* nocapture %b, i32 %o) nounwind readonly {
54entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +000055; ALL-LABEL: foo1:
56
57; MIPS32R1: sll $[[T1:[0-9]+]], $5, 3
58; MIPS32R1: addu $[[T3:[0-9]+]], $4, $[[T1]]
59; MIPS32R1: ldc1 $f0, 0($[[T3]])
60
61; MIPS32R2: sll $[[T1:[0-9]+]], $5, 3
62; MIPS32R2: ldxc1 $f0, $[[T1]]($4)
63
64; MIPS32R6: sll $[[T1:[0-9]+]], $5, 3
65; MIPS32R6: addu $[[T3:[0-9]+]], $4, $[[T1]]
66; MIPS32R6: ldc1 $f0, 0($[[T3]])
67
68; MIPS4: sll $[[T0:[0-9]+]], $5, 0
69; MIPS4: dsll $[[T1:[0-9]+]], $[[T0]], 3
70; MIPS4: ldxc1 $f0, $[[T1]]($4)
71
72; MIPS64R6: sll $[[T0:[0-9]+]], $5, 0
73; MIPS64R6: dsll $[[T1:[0-9]+]], $[[T0]], 3
74; MIPS64R6: daddu $[[T3:[0-9]+]], $4, $[[T1]]
75; MIPS64R6: ldc1 $f0, 0($[[T3]])
76
Petar Jovanovic97250162014-02-05 17:19:30 +000077; CHECK-NACL-NOT: ldxc1
Daniel Sandersfd61fd32014-06-12 14:19:28 +000078
David Blaikie79e6c742015-02-27 19:29:02 +000079 %arrayidx = getelementptr inbounds double, double* %b, i32 %o
David Blaikiea79ac142015-02-27 21:17:42 +000080 %0 = load double, double* %arrayidx, align 8
Akira Hatanaka330d9012012-02-28 02:55:02 +000081 ret double %0
82}
83
84define float @foo2(i32 %b, i32 %c) nounwind readonly {
85entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +000086; ALL-LABEL: foo2:
87
88; luxc1 did not exist in MIPS32r1
89; MIPS32R1-NOT: luxc1
90
91; luxc1 is a misnomer since it aligns the given pointer downwards and performs
92; an aligned load. We mustn't use it to handle unaligned loads.
93; MIPS32R2-NOT: luxc1
94
95; luxc1 was removed in MIPS32r6
96; MIPS32R6-NOT: luxc1
97
98; MIPS4-NOT: luxc1
99
100; luxc1 was removed in MIPS64r6
101; MIPS64R6-NOT: luxc1
102
David Blaikie79e6c742015-02-27 19:29:02 +0000103 %arrayidx1 = getelementptr inbounds [4 x %struct.S], [4 x %struct.S]* @s, i32 0, i32 %b, i32 0, i32 %c
David Blaikiea79ac142015-02-27 21:17:42 +0000104 %0 = load float, float* %arrayidx1, align 1
Akira Hatanaka330d9012012-02-28 02:55:02 +0000105 ret float %0
106}
107
108define void @foo3(float* nocapture %b, i32 %o) nounwind {
109entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000110; ALL-LABEL: foo3:
111
112; MIPS32R1-DAG: lwc1 $[[T0:f0]], 0(${{[0-9]+}})
113; MIPS32R1-DAG: addu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
114; MIPS32R1-DAG: swc1 $[[T0]], 0($[[T1]])
115
116; MIPS32R2: lwc1 $[[T0:f0]], 0(${{[0-9]+}})
117; MIPS32R2: swxc1 $[[T0]], ${{[0-9]+}}($4)
118
119; MIPS32R6-DAG: lwc1 $[[T0:f0]], 0(${{[0-9]+}})
120; MIPS32R6-DAG: addu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
121; MIPS32R6-DAG: swc1 $[[T0]], 0($[[T1]])
122
123; MIPS4: lwc1 $[[T0:f0]], 0(${{[0-9]+}})
124; MIPS4: swxc1 $[[T0]], ${{[0-9]+}}($4)
125
126; MIPS64R6-DAG: lwc1 $[[T0:f0]], 0(${{[0-9]+}})
127; MIPS64R6-DAG: daddu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
128; MIPS64R6-DAG: swc1 $[[T0]], 0($[[T1]])
129
Petar Jovanovic97250162014-02-05 17:19:30 +0000130; CHECK-NACL-NOT: swxc1
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000131
David Blaikiea79ac142015-02-27 21:17:42 +0000132 %0 = load float, float* @gf, align 4
David Blaikie79e6c742015-02-27 19:29:02 +0000133 %arrayidx = getelementptr inbounds float, float* %b, i32 %o
Akira Hatanaka330d9012012-02-28 02:55:02 +0000134 store float %0, float* %arrayidx, align 4
135 ret void
136}
137
138define void @foo4(double* nocapture %b, i32 %o) nounwind {
139entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000140; ALL-LABEL: foo4:
141
142; MIPS32R1-DAG: ldc1 $[[T0:f0]], 0(${{[0-9]+}})
143; MIPS32R1-DAG: addu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
144; MIPS32R1-DAG: sdc1 $[[T0]], 0($[[T1]])
145
146; MIPS32R2: ldc1 $[[T0:f0]], 0(${{[0-9]+}})
147; MIPS32R2: sdxc1 $[[T0]], ${{[0-9]+}}($4)
148
149; MIPS32R6-DAG: ldc1 $[[T0:f0]], 0(${{[0-9]+}})
150; MIPS32R6-DAG: addu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
151; MIPS32R6-DAG: sdc1 $[[T0]], 0($[[T1]])
152
153; MIPS4: ldc1 $[[T0:f0]], 0(${{[0-9]+}})
154; MIPS4: sdxc1 $[[T0]], ${{[0-9]+}}($4)
155
156; MIPS64R6-DAG: ldc1 $[[T0:f0]], 0(${{[0-9]+}})
157; MIPS64R6-DAG: daddu $[[T1:[0-9]+]], $4, ${{[0-9]+}}
158; MIPS64R6-DAG: sdc1 $[[T0]], 0($[[T1]])
159
Petar Jovanovic97250162014-02-05 17:19:30 +0000160; CHECK-NACL-NOT: sdxc1
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000161
David Blaikiea79ac142015-02-27 21:17:42 +0000162 %0 = load double, double* @gd, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000163 %arrayidx = getelementptr inbounds double, double* %b, i32 %o
Akira Hatanaka330d9012012-02-28 02:55:02 +0000164 store double %0, double* %arrayidx, align 8
165 ret void
166}
167
168define void @foo5(i32 %b, i32 %c) nounwind {
169entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000170; ALL-LABEL: foo5:
171
172; MIPS32R1-NOT: suxc1
173
174; MIPS32R2-NOT: suxc1
175
176; MIPS32R6-NOT: suxc1
177
178; MIPS4-NOT: suxc1
179
180; MIPS64R6-NOT: suxc1
181
David Blaikiea79ac142015-02-27 21:17:42 +0000182 %0 = load float, float* @gf, align 4
David Blaikie79e6c742015-02-27 19:29:02 +0000183 %arrayidx1 = getelementptr inbounds [4 x %struct.S], [4 x %struct.S]* @s, i32 0, i32 %b, i32 0, i32 %c
Akira Hatanaka330d9012012-02-28 02:55:02 +0000184 store float %0, float* %arrayidx1, align 1
185 ret void
186}
187
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +0000188define double @foo6(i32 %b, i32 %c) nounwind readonly {
189entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000190; ALL-LABEL: foo6:
191
192; MIPS32R1-NOT: luxc1
193
194; MIPS32R2-NOT: luxc1
195
196; MIPS32R6-NOT: luxc1
197
198; MIPS4-NOT: luxc1
199
200; MIPS64R6-NOT: luxc1
201
David Blaikie79e6c742015-02-27 19:29:02 +0000202 %arrayidx1 = getelementptr inbounds [4 x %struct.S2], [4 x %struct.S2]* @s2, i32 0, i32 %b, i32 0, i32 %c
David Blaikiea79ac142015-02-27 21:17:42 +0000203 %0 = load double, double* %arrayidx1, align 1
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +0000204 ret double %0
205}
206
207define void @foo7(i32 %b, i32 %c) nounwind {
208entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000209; ALL-LABEL: foo7:
210
211; MIPS32R1-NOT: suxc1
212
213; MIPS32R2-NOT: suxc1
214
215; MIPS32R6-NOT: suxc1
216
217; MIPS4-NOT: suxc1
218
219; MIPS64R6-NOT: suxc1
220
David Blaikiea79ac142015-02-27 21:17:42 +0000221 %0 = load double, double* @gd, align 8
David Blaikie79e6c742015-02-27 19:29:02 +0000222 %arrayidx1 = getelementptr inbounds [4 x %struct.S2], [4 x %struct.S2]* @s2, i32 0, i32 %b, i32 0, i32 %c
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +0000223 store double %0, double* %arrayidx1, align 1
224 ret void
225}
226
227define float @foo8() nounwind readonly {
228entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000229; ALL-LABEL: foo8:
230
231; MIPS32R1-NOT: luxc1
232
233; MIPS32R2-NOT: luxc1
234
235; MIPS32R6-NOT: luxc1
236
237; MIPS4-NOT: luxc1
238
239; MIPS64R6-NOT: luxc1
240
David Blaikief72d05b2015-03-13 18:20:45 +0000241 %0 = load float, float* getelementptr inbounds (%struct.S3, %struct.S3* @s3, i32 0, i32 1), align 1
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +0000242 ret float %0
243}
244
245define void @foo9(float %f) nounwind {
246entry:
Daniel Sandersfd61fd32014-06-12 14:19:28 +0000247; ALL-LABEL: foo9:
248
249; MIPS32R1-NOT: suxc1
250
251; MIPS32R2-NOT: suxc1
252
253; MIPS32R6-NOT: suxc1
254
255; MIPS4-NOT: suxc1
256
257; MIPS64R6-NOT: suxc1
258
David Blaikief72d05b2015-03-13 18:20:45 +0000259 store float %f, float* getelementptr inbounds (%struct.S3, %struct.S3* @s3, i32 0, i32 1), align 1
Akira Hatanaka6bbe1f02012-03-01 22:12:30 +0000260 ret void
261}
262