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\]+, 64" 2 } } */
46 /* { dg-final { (scan-assembler-times "ushr\\td\[0-9\]+, d\[0-9\]+, 4" 2)  || \
47    (scan-assembler-times "lsr\\tx\[0-9\]+, x\[0-9\]+, 4" 2) } } */
48 /* { dg-final { scan-assembler-not "ushr\\td\[0-9\]+, d\[0-9\]+, 0" } } */
49 
50 int
main(int argc,char * argv[])51 main (int argc, char *argv[])
52 {
53   /* Testing vshr_n_u64.  */
54   if (test_vshr_n_u64_64 (vcreate_u64 (0x0000000080000000), 0))
55     abort ();
56   if (test_vshr_n_u64_64 (vcreate_u64 (0xffffffff80000000), 0))
57     abort ();
58 
59   if (test_vshr_n_u64_4 (vcreate_u64 (0x0000000080000000), 0x0000000008000000))
60     abort ();
61   if (test_vshr_n_u64_4 (vcreate_u64 (0xffffffff80000000), 0x0ffffffff8000000))
62     abort ();
63 
64   if (test_vshr_n_u64_0 (vcreate_u64 (0x0000000080000000), 0x0000000080000000))
65     abort ();
66 
67   /* Testing vshrd_n_u64.  */
68   if (test_vshrd_n_u64_64 (0x0000000080000000, 0))
69     abort ();
70   if (test_vshrd_n_u64_64 (0xffffffff80000000, 0))
71     abort ();
72 
73   if (test_vshrd_n_u64_4 (0x0000000080000000, 0x0000000008000000))
74     abort ();
75   if (test_vshrd_n_u64_4 (0xffffffff80000000, 0x0ffffffff8000000))
76     abort ();
77 
78   if (test_vshrd_n_u64_0 (0x0000000080000000, 0x0000000080000000))
79     abort ();
80 
81   return 0;
82 }
83 
84 /* { dg-final { cleanup-saved-temps } } */
85