summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/vdup_lane_2.c
blob: a49db3e963db5309c5dafc25a029ef7c557aaf3f (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
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/* Test vdup_lane intrinsics work correctly.  */
/* { dg-do run } */
/* { dg-options "-O1 --save-temps" } */

#include <arm_neon.h>

#define force_simd(V1) asm volatile ("mov %d0, %1.d[0]" \
         : "=w"(V1)                                     \
         : "w"(V1)                                      \
         : /* No clobbers */)

extern void abort (void);

float32_t __attribute__ ((noinline))
wrap_vdups_lane_f32_0 (float32x2_t dummy, float32x2_t a)
{
  return vdups_lane_f32 (a, 0);
}

float32_t __attribute__ ((noinline))
wrap_vdups_lane_f32_1 (float32x2_t a)
{
  return vdups_lane_f32 (a, 1);
}

int __attribute__ ((noinline))
test_vdups_lane_f32 ()
{
  float32x2_t a;
  float32_t b;
  float32_t c[2] = { 0.0, 1.0 };

  a = vld1_f32 (c);
  b = wrap_vdups_lane_f32_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vdups_lane_f32_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

float64_t __attribute__ ((noinline))
wrap_vdupd_lane_f64_0 (float64x1_t dummy, float64x1_t a)
{
  return vdupd_lane_f64 (a, 0);
}

int __attribute__ ((noinline))
test_vdupd_lane_f64 ()
{
  float64x1_t a;
  float64_t b;
  float64_t c[1] = { 0.0 };
  a = vld1_f64 (c);
  b = wrap_vdupd_lane_f64_0 (a, a);
  if (c[0] != b)
    return 1;
  return 0;
}

int8_t __attribute__ ((noinline))
wrap_vdupb_lane_s8_0 (int8x8_t dummy, int8x8_t a)
{
  int8_t result = vdupb_lane_s8 (a, 0);
  force_simd (result);
  return result;
}

int8_t __attribute__ ((noinline))
wrap_vdupb_lane_s8_1 (int8x8_t a)
{
  int8_t result = vdupb_lane_s8 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vdupb_lane_s8 ()
{
  int8x8_t a;
  int8_t b;
  int8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };

  a = vld1_s8 (c);
  b = wrap_vdupb_lane_s8_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vdupb_lane_s8_1 (a);
  if (c[1] != b)
    return 1;

  return 0;
}

uint8_t __attribute__ ((noinline))
wrap_vdupb_lane_u8_0 (uint8x8_t dummy, uint8x8_t a)
{
  uint8_t result = vdupb_lane_u8 (a, 0);
  force_simd (result);
  return result;
}

uint8_t __attribute__ ((noinline))
wrap_vdupb_lane_u8_1 (uint8x8_t a)
{
  uint8_t result = vdupb_lane_u8 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vdupb_lane_u8 ()
{
  uint8x8_t a;
  uint8_t b;
  uint8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };

  a = vld1_u8 (c);
  b = wrap_vdupb_lane_u8_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vdupb_lane_u8_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

int16_t __attribute__ ((noinline))
wrap_vduph_lane_s16_0 (int16x4_t dummy, int16x4_t a)
{
  int16_t result = vduph_lane_s16 (a, 0);
  force_simd (result);
  return result;
}

int16_t __attribute__ ((noinline))
wrap_vduph_lane_s16_1 (int16x4_t a)
{
  int16_t result = vduph_lane_s16 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vduph_lane_s16 ()
{
  int16x4_t a;
  int16_t b;
  int16_t c[4] = { 0, 1, 2, 3 };

  a = vld1_s16 (c);
  b = wrap_vduph_lane_s16_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vduph_lane_s16_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

uint16_t __attribute__ ((noinline))
wrap_vduph_lane_u16_0 (uint16x4_t dummy, uint16x4_t a)
{
  uint16_t result = vduph_lane_u16 (a, 0);
  force_simd (result);
  return result;
}

uint16_t __attribute__ ((noinline))
wrap_vduph_lane_u16_1 (uint16x4_t a)
{
  uint16_t result = vduph_lane_u16 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vduph_lane_u16 ()
{
  uint16x4_t a;
  uint16_t b;
  uint16_t c[4] = { 0, 1, 2, 3 };

  a = vld1_u16 (c);
  b = wrap_vduph_lane_u16_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vduph_lane_u16_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

int32_t __attribute__ ((noinline))
wrap_vdups_lane_s32_0 (int32x2_t dummy, int32x2_t a)
{
  int32_t result = vdups_lane_s32 (a, 0);
  force_simd (result);
  return result;
}

int32_t __attribute__ ((noinline))
wrap_vdups_lane_s32_1 (int32x2_t a)
{
  int32_t result = vdups_lane_s32 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vdups_lane_s32 ()
{
  int32x2_t a;
  int32_t b;
  int32_t c[2] = { 0, 1 };

  a = vld1_s32 (c);
  b = wrap_vdups_lane_s32_0 (vcreate_s32 (0), a);
  if (c[0] != b)
    return 1;
  b = wrap_vdups_lane_s32_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

uint32_t __attribute__ ((noinline))
wrap_vdups_lane_u32_0 (uint32x2_t dummy, uint32x2_t a)
{
  uint32_t result = vdups_lane_u32 (a, 0);
  force_simd (result);
  return result;
}

uint32_t __attribute__ ((noinline))
wrap_vdups_lane_u32_1 (uint32x2_t a)
{
  uint32_t result = vdups_lane_u32 (a, 1);
  force_simd (result);
  return result;
}

int __attribute__ ((noinline))
test_vdups_lane_u32 ()
{
  uint32x2_t a;
  uint32_t b;
  uint32_t c[2] = { 0, 1 };
  a = vld1_u32 (c);
  b = wrap_vdups_lane_u32_0 (a, a);
  if (c[0] != b)
    return 1;
  b = wrap_vdups_lane_u32_1 (a);
  if (c[1] != b)
    return 1;
  return 0;
}

uint64_t __attribute__ ((noinline))
wrap_vdupd_lane_u64_0 (uint64x1_t dummy, uint64x1_t a)
{
  return vdupd_lane_u64 (a, 0);;
}

int __attribute__ ((noinline))
test_vdupd_lane_u64 ()
{
  uint64x1_t a;
  uint64_t b;
  uint64_t c[1] = { 0 };

  a = vld1_u64 (c);
  b = wrap_vdupd_lane_u64_0 (a, a);
  if (c[0] != b)
    return 1;
  return 0;
}

int64_t __attribute__ ((noinline))
wrap_vdupd_lane_s64_0 (int64x1_t dummy, int64x1_t a)
{
  return vdupd_lane_s64 (a, 0);
}

int __attribute__ ((noinline))
test_vdupd_lane_s64 ()
{
  int64x1_t a;
  int64_t b;
  int64_t c[1] = { 0 };

  a = vld1_s64 (c);
  b = wrap_vdupd_lane_s64_0 (a, a);
  if (c[0] != b)
    return 1;
  return 0;
}

int
main ()
{
  if (test_vdups_lane_f32 ())
    abort ();
  if (test_vdupd_lane_f64 ())
    abort ();
  if (test_vdupb_lane_s8 ())
    abort ();
  if (test_vdupb_lane_u8 ())
    abort ();
  if (test_vduph_lane_s16 ())
    abort ();
  if (test_vduph_lane_u16 ())
    abort ();
  if (test_vdups_lane_s32 ())
    abort ();
  if (test_vdups_lane_u32 ())
    abort ();
  if (test_vdupd_lane_s64 ())
    abort ();
  if (test_vdupd_lane_u64 ())
    abort ();
  return 0;
}

/* Asm check for vdupb_lane_s8, vdupb_lane_u8.  */
/* { dg-final { scan-assembler-not "dup\\tb\[0-9\]+, v\[0-9\]+\.b\\\[0\\\]" } } */
/* { dg-final { scan-assembler-times "dup\\tb\[0-9\]+, v\[0-9\]+\.b\\\[1\\\]" 2 } } */

/* Asm check for vduph_lane_h16, vduph_lane_h16.  */
/* { dg-final { scan-assembler-not "dup\\th\[0-9\]+, v\[0-9\]+\.h\\\[0\\\]" } } */
/* { dg-final { scan-assembler-times "dup\\th\[0-9\]+, v\[0-9\]+\.h\\\[1\\\]" 2 } } */

/* Asm check for vdups_lane_f32, vdups_lane_s32, vdups_lane_u32.  */
/* Can't generate "dup s<n>, v<m>[0]" for vdups_lane_s32 and vdups_lane_u32.  */
/* { dg-final { scan-assembler-times "dup\\ts\[0-9\]+, v\[0-9\]+\.s\\\[0\\\]" 1} } */
/* { dg-final { scan-assembler-times "dup\\ts\[0-9\]+, v\[0-9\]+\.s\\\[1\\\]" 3 } } */

/* Asm check for vdupd_lane_f64, vdupd_lane_s64, vdupd_lane_u64.  */
/* Attempts to make the compiler generate vdupd are not practical.  */
/* { dg-final { scan-assembler-not "dup\\td\[0-9\]+, v\[0-9\]+\.d\\\[0\\\]" } } */