[PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / mul_intrinsic_1.c
blob00ef4f2de6c5510638b7e31990c0754f60d3e4d0
1 /* { dg-do run } */
2 /* { dg-options "-O3 --save-temps" } */
4 #include <arm_neon.h>
6 extern void abort (void);
8 #define MAPs(size, xx) int##size##xx##_t
9 #define MAPu(size, xx) uint##size##xx##_t
12 #define TEST_VMUL(q, su, size, in1_lanes, in2_lanes) \
13 static void \
14 test_vmulq_lane##q##_##su##size (MAP##su (size, ) * res, \
15 const MAP##su(size, ) *in1, \
16 const MAP##su(size, ) *in2) \
17 { \
18 MAP##su (size, x##in1_lanes) a = vld1q_##su##size (in1); \
19 MAP##su (size, x##in2_lanes) b = vld1##q##_##su##size (in2); \
20 a = vmulq_lane##q##_##su##size (a, b, 1); \
21 vst1q_##su##size (res, a); \
24 #define BUILD_VARS(width, n_lanes, n_half_lanes) \
25 TEST_VMUL (, s, width, n_lanes, n_half_lanes) \
26 TEST_VMUL (q, s, width, n_lanes, n_lanes) \
27 TEST_VMUL (, u, width, n_lanes, n_half_lanes) \
28 TEST_VMUL (q, u, width, n_lanes, n_lanes) \
30 BUILD_VARS (32, 4, 2)
31 BUILD_VARS (16, 8, 4)
33 #define POOL4 {0, 1, 2, 3}
34 #define POOL8 {0, 1, 2, 3, 4, 5, 6, 7}
35 #define EMPTY4 {0, 0, 0, 0}
36 #define EMPTY8 {0, 0, 0, 0, 0, 0, 0, 0}
38 #define BUILD_TEST(su, size, lanes) \
39 static void \
40 test_##su##size (void) \
41 { \
42 int i; \
43 MAP##su (size,) pool[lanes] = POOL##lanes; \
44 MAP##su (size,) res[lanes] = EMPTY##lanes; \
45 MAP##su (size,) res2[lanes] = EMPTY##lanes; \
47 /* Forecfully avoid optimization. */ \
48 asm volatile ("" : : : "memory"); \
49 test_vmulq_lane_##su##size (res, pool, pool); \
50 for (i = 0; i < lanes; i++) \
51 if (res[i] != pool[i]) \
52 abort (); \
54 /* Forecfully avoid optimization. */ \
55 asm volatile ("" : : : "memory"); \
56 test_vmulq_laneq_##su##size (res2, pool, pool); \
57 for (i = 0; i < lanes; i++) \
58 if (res2[i] != pool[i]) \
59 abort (); \
62 #undef BUILD_VARS
63 #define BUILD_VARS(size, lanes) \
64 BUILD_TEST (s, size, lanes) \
65 BUILD_TEST (u, size, lanes)
67 BUILD_VARS (32, 4)
68 BUILD_VARS (16, 8)
70 int
71 main (int argc, char **argv)
73 test_s32 ();
74 test_u32 ();
75 test_s16 ();
76 test_u16 ();
77 return 0;
80 /* { dg-final { scan-assembler-times "mul\\tv\[0-9\]+\.4s, v\[0-9\]+\.4s, v\[0-9\]+\.s\\\[\[0-9\]+\\\]" 4 } } */
81 /* { dg-final { scan-assembler-times "mul\\tv\[0-9\]+\.8h, v\[0-9\]+\.8h, v\[0-9\]+\.h\\\[\[0-9\]+\\\]" 4 } } */