2 /* { dg-options "-O3 --save-temps -ffast-math" } */
6 extern void abort (void);
11 int8_t input_int8
[] = {1, 56, 2, -9, -90, 23, 54, 76,
12 -4, 34, 110, -110, 6, 4, 75, -34};
13 int16_t input_int16
[] = {1, 56, 2, -9, -90, 23, 54, 76,
14 -4, 34, 110, -110, 6, 4, 75, -34};
15 int32_t input_int32
[] = {1, 56, 2, -9, -90, 23, 54, 76,
16 -4, 34, 110, -110, 6, 4, 75, -34};
18 uint8_t input_uint8
[] = {1, 56, 2, 9, 90, 23, 54, 76,
19 4, 34, 110, 110, 6, 4, 75, 34};
20 uint16_t input_uint16
[] = {1, 56, 2, 9, 90, 23, 54, 76,
21 4, 34, 110, 110, 6, 4, 75, 34};
22 uint32_t input_uint32
[] = {1, 56, 2, 9, 90, 23, 54, 76,
23 4, 34, 110, 110, 6, 4, 75, 34};
25 #define EQUAL(a, b) (a == b)
27 #define TEST(MAXMIN, CMP_OP, SUFFIX, Q, TYPE, LANES) \
29 test_v##MAXMIN##v##SUFFIX##_##TYPE##x##LANES##_t (void) \
32 int moves = (NUM_TESTS - LANES) + 1; \
33 TYPE##_t out_l[NUM_TESTS]; \
34 TYPE##_t out_v[NUM_TESTS]; \
36 /* Calculate linearly. */ \
37 for (i = 0; i < moves; i++) \
39 out_l[i] = input_##TYPE[i]; \
40 for (j = 0; j < LANES; j++) \
41 out_l[i] = input_##TYPE[i + j] CMP_OP out_l[i] ? \
42 input_##TYPE[i + j] : out_l[i]; \
45 /* Calculate using vector reduction intrinsics. */ \
46 for (i = 0; i < moves; i++) \
48 TYPE##x##LANES##_t t1 = vld1##Q##_##SUFFIX (input_##TYPE + i); \
49 out_v[i] = v##MAXMIN##v##Q##_##SUFFIX (t1); \
53 for (i = 0; i < moves; i++) \
55 if (!EQUAL (out_v[i], out_l[i])) \
61 #define BUILD_VARIANTS(TYPE, STYPE, W32, W64) \
62 TEST (max, >, STYPE, , TYPE, W32) \
63 TEST (max, >, STYPE, q, TYPE, W64) \
64 TEST (min, <, STYPE, , TYPE, W32) \
65 TEST (min, <, STYPE, q, TYPE, W64)
67 BUILD_VARIANTS (int8
, s8
, 8, 16)
68 /* { dg-final { scan-assembler "smaxv\\tb\[0-9\]+, v\[0-9\]+\.8b" } } */
69 /* { dg-final { scan-assembler "sminv\\tb\[0-9\]+, v\[0-9\]+\.8b" } } */
70 /* { dg-final { scan-assembler "smaxv\\tb\[0-9\]+, v\[0-9\]+\.16b" } } */
71 /* { dg-final { scan-assembler "sminv\\tb\[0-9\]+, v\[0-9\]+\.16b" } } */
72 BUILD_VARIANTS (uint8
, u8
, 8, 16)
73 /* { dg-final { scan-assembler "umaxv\\tb\[0-9\]+, v\[0-9\]+\.8b" } } */
74 /* { dg-final { scan-assembler "uminv\\tb\[0-9\]+, v\[0-9\]+\.8b" } } */
75 /* { dg-final { scan-assembler "umaxv\\tb\[0-9\]+, v\[0-9\]+\.16b" } } */
76 /* { dg-final { scan-assembler "uminv\\tb\[0-9\]+, v\[0-9\]+\.16b" } } */
77 BUILD_VARIANTS (int16
, s16
, 4, 8)
78 /* { dg-final { scan-assembler "smaxv\\th\[0-9\]+, v\[0-9\]+\.4h" } } */
79 /* { dg-final { scan-assembler "sminv\\th\[0-9\]+, v\[0-9\]+\.4h" } } */
80 /* { dg-final { scan-assembler "smaxv\\th\[0-9\]+, v\[0-9\]+\.8h" } } */
81 /* { dg-final { scan-assembler "sminv\\th\[0-9\]+, v\[0-9\]+\.8h" } } */
82 BUILD_VARIANTS (uint16
, u16
, 4, 8)
83 /* { dg-final { scan-assembler "umaxv\\th\[0-9\]+, v\[0-9\]+\.4h" } } */
84 /* { dg-final { scan-assembler "uminv\\th\[0-9\]+, v\[0-9\]+\.4h" } } */
85 /* { dg-final { scan-assembler "umaxv\\th\[0-9\]+, v\[0-9\]+\.8h" } } */
86 /* { dg-final { scan-assembler "uminv\\th\[0-9\]+, v\[0-9\]+\.8h" } } */
87 BUILD_VARIANTS (int32
, s32
, 2, 4)
88 /* { dg-final { scan-assembler "smaxp\\tv\[0-9\]+\.2s, v\[0-9\]+\.2s, v\[0-9\]+\.2s" } } */
89 /* { dg-final { scan-assembler "sminp\\tv\[0-9\]+\.2s, v\[0-9\]+\.2s, v\[0-9\]+\.2s" } } */
90 /* { dg-final { scan-assembler "smaxv\\ts\[0-9\]+, v\[0-9\]+\.4s" } } */
91 /* { dg-final { scan-assembler "sminv\\ts\[0-9\]+, v\[0-9\]+\.4s" } } */
92 BUILD_VARIANTS (uint32
, u32
, 2, 4)
93 /* { dg-final { scan-assembler "umaxp\\tv\[0-9\]+\.2s, v\[0-9\]+\.2s, v\[0-9\]+\.2s" } } */
94 /* { dg-final { scan-assembler "uminp\\tv\[0-9\]+\.2s, v\[0-9\]+\.2s, v\[0-9\]+\.2s" } } */
95 /* { dg-final { scan-assembler "umaxv\\ts\[0-9\]+, v\[0-9\]+\.4s" } } */
96 /* { dg-final { scan-assembler "uminv\\ts\[0-9\]+, v\[0-9\]+\.4s" } } */
99 #define TEST(MAXMIN, CMP_OP, SUFFIX, Q, TYPE, LANES) \
101 if (!test_v##MAXMIN##v##SUFFIX##_##TYPE##x##LANES##_t ()) \
106 main (int argc
, char **argv
)
108 BUILD_VARIANTS (int8
, s8
, 8, 16)
109 BUILD_VARIANTS (uint8
, u8
, 8, 16)
110 BUILD_VARIANTS (int16
, s16
, 4, 8)
111 BUILD_VARIANTS (uint16
, u16
, 4, 8)
112 BUILD_VARIANTS (int32
, s32
, 2, 4)
113 BUILD_VARIANTS (uint32
, u32
, 2, 4)
117 /* { dg-final { cleanup-saved-temps } } */