1 /* Test logical SIMD shift works correctly. */
2 /* { dg-do run } */
3 /* { dg-options "--save-temps" } */
4
5 #include "arm_neon.h"
6
7 extern void abort (void);
8
9 int __attribute__ ((noinline))
test_vshr_n_u64_64(uint64x1_t passed,uint64_t expected)10 test_vshr_n_u64_64 (uint64x1_t passed, uint64_t expected)
11 {
12 return vget_lane_u64 (vshr_n_u64 (passed, 64), 0) != expected;
13 }
14
15 int __attribute__ ((noinline))
test_vshr_n_u64_4(uint64x1_t passed,uint64_t expected)16 test_vshr_n_u64_4 (uint64x1_t passed, uint64_t expected)
17 {
18 return vget_lane_u64 (vshr_n_u64 (passed, 4), 0) != expected;
19 }
20
21 int __attribute__ ((noinline))
test_vshr_n_u64_0(uint64x1_t passed,uint64_t expected)22 test_vshr_n_u64_0 (uint64x1_t passed, uint64_t expected)
23 {
24 return vget_lane_u64 (vshr_n_u64 (passed, 0), 0) != expected;
25 }
26
27 int __attribute__ ((noinline))
test_vshrd_n_u64_64(uint64_t passed,uint64_t expected)28 test_vshrd_n_u64_64 (uint64_t passed, uint64_t expected)
29 {
30 return vshrd_n_u64 (passed, 64) != expected;
31 }
32
33 int __attribute__ ((noinline))
test_vshrd_n_u64_4(uint64_t passed,uint64_t expected)34 test_vshrd_n_u64_4 (uint64_t passed, uint64_t expected)
35 {
36 return vshrd_n_u64 (passed, 4) != expected;
37 }
38
39 int __attribute__ ((noinline))
test_vshrd_n_u64_0(uint64_t passed,uint64_t expected)40 test_vshrd_n_u64_0 (uint64_t passed, uint64_t expected)
41 {
42 return vshrd_n_u64 (passed, 0) != expected;
43 }
44
45 /* { dg-final { (scan-assembler-times "ushr\\td\[0-9\]+, d\[0-9\]+, 4" 2) || \
46 (scan-assembler-times "lsr\\tx\[0-9\]+, x\[0-9\]+, 4" 2) } } */
47 /* { dg-final { scan-assembler-not "ushr\\td\[0-9\]+, d\[0-9\]+, 0" } } */
48
49 int
main(int argc,char * argv[])50 main (int argc, char *argv[])
51 {
52 /* Testing vshr_n_u64. */
53 if (test_vshr_n_u64_64 (vcreate_u64 (0x0000000080000000), 0))
54 abort ();
55 if (test_vshr_n_u64_64 (vcreate_u64 (0xffffffff80000000), 0))
56 abort ();
57
58 if (test_vshr_n_u64_4 (vcreate_u64 (0x0000000080000000), 0x0000000008000000))
59 abort ();
60 if (test_vshr_n_u64_4 (vcreate_u64 (0xffffffff80000000), 0x0ffffffff8000000))
61 abort ();
62
63 if (test_vshr_n_u64_0 (vcreate_u64 (0x0000000080000000), 0x0000000080000000))
64 abort ();
65
66 /* Testing vshrd_n_u64. */
67 if (test_vshrd_n_u64_64 (0x0000000080000000, 0))
68 abort ();
69 if (test_vshrd_n_u64_64 (0xffffffff80000000, 0))
70 abort ();
71
72 if (test_vshrd_n_u64_4 (0x0000000080000000, 0x0000000008000000))
73 abort ();
74 if (test_vshrd_n_u64_4 (0xffffffff80000000, 0x0ffffffff8000000))
75 abort ();
76
77 if (test_vshrd_n_u64_0 (0x0000000080000000, 0x0000000080000000))
78 abort ();
79
80 return 0;
81 }
82
83