PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / arm / armv8_2-fp16-arith-2.c
blob24d0528540d58a43b896dd88c64c23b823553e96
1 /* { dg-do compile } */
2 /* { dg-require-effective-target arm_v8_2a_fp16_neon_ok } */
3 /* { dg-options "-O2 -fno-fast-math" } */
4 /* { dg-add-options arm_v8_2a_fp16_neon } */
6 /* Test instructions generated for half-precision arithmetic without
7 unsafe-math-optimizations. */
9 typedef __fp16 float16_t;
10 typedef __simd64_float16_t float16x4_t;
11 typedef __simd128_float16_t float16x8_t;
13 typedef short int16x4_t __attribute__ ((vector_size (8)));
14 typedef short int int16x8_t __attribute__ ((vector_size (16)));
16 float16_t
17 fp16_abs (float16_t a)
19 return (a < 0) ? -a : a;
22 #define TEST_UNOP(NAME, OPERATOR, TY) \
23 TY test_##NAME##_##TY (TY a) \
24 { \
25 return OPERATOR (a); \
28 #define TEST_BINOP(NAME, OPERATOR, TY) \
29 TY test_##NAME##_##TY (TY a, TY b) \
30 { \
31 return a OPERATOR b; \
34 #define TEST_CMP(NAME, OPERATOR, RTY, TY) \
35 RTY test_##NAME##_##TY (TY a, TY b) \
36 { \
37 return a OPERATOR b; \
40 /* Scalars. */
42 TEST_UNOP (neg, -, float16_t)
43 TEST_UNOP (abs, fp16_abs, float16_t)
45 TEST_BINOP (add, +, float16_t)
46 TEST_BINOP (sub, -, float16_t)
47 TEST_BINOP (mult, *, float16_t)
48 TEST_BINOP (div, /, float16_t)
50 TEST_CMP (equal, ==, int, float16_t)
51 TEST_CMP (unequal, !=, int, float16_t)
52 TEST_CMP (lessthan, <, int, float16_t)
53 TEST_CMP (greaterthan, >, int, float16_t)
54 TEST_CMP (lessthanequal, <=, int, float16_t)
55 TEST_CMP (greaterthanqual, >=, int, float16_t)
57 /* Vectors of size 4. */
59 TEST_UNOP (neg, -, float16x4_t)
61 TEST_BINOP (add, +, float16x4_t)
62 TEST_BINOP (sub, -, float16x4_t)
63 TEST_BINOP (mult, *, float16x4_t)
64 TEST_BINOP (div, /, float16x4_t)
66 TEST_CMP (equal, ==, int16x4_t, float16x4_t)
67 TEST_CMP (unequal, !=, int16x4_t, float16x4_t)
68 TEST_CMP (lessthan, <, int16x4_t, float16x4_t)
69 TEST_CMP (greaterthan, >, int16x4_t, float16x4_t)
70 TEST_CMP (lessthanequal, <=, int16x4_t, float16x4_t)
71 TEST_CMP (greaterthanqual, >=, int16x4_t, float16x4_t)
73 /* Vectors of size 8. */
75 TEST_UNOP (neg, -, float16x8_t)
77 TEST_BINOP (add, +, float16x8_t)
78 TEST_BINOP (sub, -, float16x8_t)
79 TEST_BINOP (mult, *, float16x8_t)
80 TEST_BINOP (div, /, float16x8_t)
82 TEST_CMP (equal, ==, int16x8_t, float16x8_t)
83 TEST_CMP (unequal, !=, int16x8_t, float16x8_t)
84 TEST_CMP (lessthan, <, int16x8_t, float16x8_t)
85 TEST_CMP (greaterthan, >, int16x8_t, float16x8_t)
86 TEST_CMP (lessthanequal, <=, int16x8_t, float16x8_t)
87 TEST_CMP (greaterthanqual, >=, int16x8_t, float16x8_t)
89 /* { dg-final { scan-assembler-times {vneg\.f16\ts[0-9]+, s[0-9]+} 1 } } */
90 /* { dg-final { scan-assembler-times {vneg\.f16\td[0-9]+, d[0-9]+} 1 } } */
91 /* { dg-final { scan-assembler-times {vneg\.f16\tq[0-9]+, q[0-9]+} 1 } } */
93 /* { dg-final { scan-assembler-times {vadd\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 13 } } */
94 /* { dg-final { scan-assembler-times {vsub\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 13 } } */
95 /* { dg-final { scan-assembler-times {vmul\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 13 } } */
96 /* { dg-final { scan-assembler-times {vdiv\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 13 } } */
97 /* { dg-final { scan-assembler-times {vcmp\.f32\ts[0-9]+, s[0-9]+} 26 } } */
99 /* { dg-final { scan-assembler-times {vcmpe\.f32\ts[0-9]+, s[0-9]+} 52 } } */
100 /* { dg-final { scan-assembler-times {vcmpe\.f32\ts[0-9]+, #0} 2 } } */
102 /* { dg-final { scan-assembler-not {vabs\.f16} } } */
104 /* { dg-final { scan-assembler-not {vadd\.f32} } } */
105 /* { dg-final { scan-assembler-not {vsub\.f32} } } */
106 /* { dg-final { scan-assembler-not {vmul\.f32} } } */
107 /* { dg-final { scan-assembler-not {vdiv\.f32} } } */
108 /* { dg-final { scan-assembler-not {vcmp\.f16} } } */
109 /* { dg-final { scan-assembler-not {vcmpe\.f16} } } */