2016-11-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / gcc / testsuite / gcc.target / arm / armv8_2-fp16-move-1.c
blobbb4e68fda0767b9963d2968c3e2dd2594847c701
1 /* { dg-do compile } */
2 /* { dg-require-effective-target arm_v8_2a_fp16_scalar_ok } */
3 /* { dg-options "-O2" } */
4 /* { dg-add-options arm_v8_2a_fp16_scalar } */
6 __fp16
7 test_load_1 (__fp16* a)
9 return *a;
12 __fp16
13 test_load_2 (__fp16* a, int i)
15 return a[i];
18 /* { dg-final { scan-assembler-times {vld1\.16\t\{d[0-9]+\[[0-9]+\]\}, \[r[0-9]+\]} 2 } } */
20 void
21 test_store_1 (__fp16* a, __fp16 b)
23 *a = b;
26 void
27 test_store_2 (__fp16* a, int i, __fp16 b)
29 a[i] = b;
32 /* { dg-final { scan-assembler-times {vst1\.16\t\{d[0-9]+\[[0-9]+\]\}, \[r[0-9]+\]} 2 } } */
34 __fp16
35 test_load_store_1 (__fp16* a, int i, __fp16* b)
37 a[i] = b[i];
40 __fp16
41 test_load_store_2 (__fp16* a, int i, __fp16* b)
43 a[i] = b[i + 2];
44 return a[i];
46 /* { dg-final { scan-assembler-times {ldrh\tr[0-9]+} 2 } } */
47 /* { dg-final { scan-assembler-times {strh\tr[0-9]+} 2 } } */
49 __fp16
50 test_select_1 (int sel, __fp16 a, __fp16 b)
52 if (sel)
53 return a;
54 else
55 return b;
58 __fp16
59 test_select_2 (int sel, __fp16 a, __fp16 b)
61 return sel ? a : b;
64 __fp16
65 test_select_3 (__fp16 a, __fp16 b, __fp16 c)
67 return (a == b) ? b : c;
70 __fp16
71 test_select_4 (__fp16 a, __fp16 b, __fp16 c)
73 return (a != b) ? b : c;
76 __fp16
77 test_select_5 (__fp16 a, __fp16 b, __fp16 c)
79 return (a < b) ? b : c;
82 __fp16
83 test_select_6 (__fp16 a, __fp16 b, __fp16 c)
85 return (a <= b) ? b : c;
88 __fp16
89 test_select_7 (__fp16 a, __fp16 b, __fp16 c)
91 return (a > b) ? b : c;
94 __fp16
95 test_select_8 (__fp16 a, __fp16 b, __fp16 c)
97 return (a >= b) ? b : c;
100 /* { dg-final { scan-assembler-times {vseleq\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 4 } } */
101 /* { dg-final { scan-assembler-times {vselgt\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
102 /* { dg-final { scan-assembler-times {vselge\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
104 /* { dg-final { scan-assembler-times {vmov\.f16\ts[0-9]+, r[0-9]+} 4 } } */
105 /* { dg-final { scan-assembler-times {vmov\.f16\tr[0-9]+, s[0-9]+} 4 } } */
108 test_compare_1 (__fp16 a, __fp16 b)
110 if (a == b)
111 return -1;
112 else
113 return 0;
117 test_compare_ (__fp16 a, __fp16 b)
119 if (a != b)
120 return -1;
121 else
122 return 0;
126 test_compare_2 (__fp16 a, __fp16 b)
128 if (a > b)
129 return -1;
130 else
131 return 0;
135 test_compare_3 (__fp16 a, __fp16 b)
137 if (a >= b)
138 return -1;
139 else
140 return 0;
144 test_compare_4 (__fp16 a, __fp16 b)
146 if (a < b)
147 return -1;
148 else
149 return 0;
153 test_compare_5 (__fp16 a, __fp16 b)
155 if (a <= b)
156 return -1;
157 else
158 return 0;
161 /* { dg-final { scan-assembler-not {vcmp\.f16} } } */
162 /* { dg-final { scan-assembler-not {vcmpe\.f16} } } */
164 /* { dg-final { scan-assembler-times {vcmp\.f32} 4 } } */
165 /* { dg-final { scan-assembler-times {vcmpe\.f32} 8 } } */