1 /* { dg-do compile } */
2 /* { dg-options "-O3" } */
3 
4 #pragma GCC target "+nosve"
5 
6 #define MAX(x, y) ((x) > (y) ? (x) : (y))
7 #define MIN(x, y) ((x) < (y) ? (x) : (y))
8 #define N 1024
9 
10 #define FUNC(T)								\
11 void									\
12 sabd_##T (signed T * restrict a, signed T * restrict b,		\
13 		signed T * restrict out)				\
14 {									\
15   for (int i = 0; i < N; i++)						\
16     out[i] = MAX (a[i], b[i]) - MIN (a[i], b[i]);			\
17 }									\
18 									\
19 void									\
20 uabd_##T (unsigned T * restrict a, unsigned T * restrict b,	\
21 		  unsigned T * restrict out)				\
22 {									\
23   for (int i = 0; i < N; i++)						\
24     out[i] = MAX (a[i], b[i]) - MIN (a[i], b[i]);			\
25 }
26 
27 FUNC(char)
28 FUNC(short)
29 FUNC(int)
30 
31 /* { dg-final { scan-assembler-times "sabd\\tv\[0-9\]+\.16b, v\[0-9\]+\.16b, v\[0-9\]+\.16b" 1 } } */
32 /* { dg-final { scan-assembler-times "uabd\\tv\[0-9\]+\.16b, v\[0-9\]+\.16b, v\[0-9\]+\.16b" 1 } } */
33 /* { dg-final { scan-assembler-times "sabd\\tv\[0-9\]+\.8h, v\[0-9\]+\.8h, v\[0-9\]+\.8h" 1 } } */
34 /* { dg-final { scan-assembler-times "uabd\\tv\[0-9\]+\.8h, v\[0-9\]+\.8h, v\[0-9\]+\.8h" 1 } } */
35 /* { dg-final { scan-assembler-times "sabd\\tv\[0-9\]+\.4s, v\[0-9\]+\.4s, v\[0-9\]+\.4s" 1 } } */
36 /* { dg-final { scan-assembler-times "uabd\\tv\[0-9\]+\.4s, v\[0-9\]+\.4s, v\[0-9\]+\.4s" 1 } } */
37