1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */
3 
4 #include <stdint.h>
5 
6 #define eq(A, B) ((A) == (B))
7 #define ne(A, B) ((A) != (B))
8 #define olt(A, B) ((A) < (B))
9 #define ole(A, B) ((A) <= (B))
10 #define oge(A, B) ((A) >= (B))
11 #define ogt(A, B) ((A) > (B))
12 #define ordered(A, B) (!__builtin_isunordered (A, B))
13 #define unordered(A, B) (__builtin_isunordered (A, B))
14 #define ueq(A, B) (!__builtin_islessgreater (A, B))
15 #define ult(A, B) (__builtin_isless (A, B))
16 #define ule(A, B) (__builtin_islessequal (A, B))
17 #define uge(A, B) (__builtin_isgreaterequal (A, B))
18 #define ugt(A, B) (__builtin_isgreater (A, B))
19 #define nueq(A, B) (__builtin_islessgreater (A, B))
20 #define nult(A, B) (!__builtin_isless (A, B))
21 #define nule(A, B) (!__builtin_islessequal (A, B))
22 #define nuge(A, B) (!__builtin_isgreaterequal (A, B))
23 #define nugt(A, B) (!__builtin_isgreater (A, B))
24 
25 #define TEST_LOOP(TYPE1, TYPE2, CMP)				\
26   void __attribute__ ((noinline, noclone))			\
27   test_##TYPE1##_##TYPE2##_##CMP##_var (TYPE1 *restrict dest,	\
28 					TYPE1 *restrict src,	\
29 					TYPE1 fallback,		\
30 					TYPE2 *restrict a,	\
31 					TYPE2 *restrict b,	\
32 					int count)		\
33   {								\
34     for (int i = 0; i < count; ++i)				\
35       dest[i] = CMP (a[i], b[i]) ? src[i] : fallback;		\
36   }
37 
38 #define TEST_CMP(CMP) \
39   TEST_LOOP (int64_t, float, CMP) \
40   TEST_LOOP (uint64_t, float, CMP) \
41   TEST_LOOP (int32_t, double, CMP) \
42   TEST_LOOP (uint32_t, double, CMP)
43 
44 TEST_CMP (eq)
45 TEST_CMP (ne)
46 TEST_CMP (olt)
47 TEST_CMP (ole)
48 TEST_CMP (oge)
49 TEST_CMP (ogt)
50 TEST_CMP (ordered)
51 TEST_CMP (unordered)
52 TEST_CMP (ueq)
53 TEST_CMP (ult)
54 TEST_CMP (ule)
55 TEST_CMP (uge)
56 TEST_CMP (ugt)
57 TEST_CMP (nueq)
58 TEST_CMP (nult)
59 TEST_CMP (nule)
60 TEST_CMP (nuge)
61 TEST_CMP (nugt)
62 
63 /* 2 each for: eq, ne, ueq, nueq.  */
64 /* { dg-final { scan-assembler-times {\tfcm(?:eq|ne)\tp[0-9]+\.s, p[0-7]/z, z[0-9]+\.s, z[0-9]+\.s\n} 8 { xfail *-*-* } } } */
65 /* { dg-final { scan-assembler-times {\tfcm(?:eq|ne)\tp[0-9]+\.d, p[0-7]/z, z[0-9]+\.d, z[0-9]+\.d\n} 16 { xfail *-*-* } } } */
66 
67 /* 2 each for: olt, ult, nult, ogt, ugt, nugt.  */
68 /* { dg-final { scan-assembler-times {\tfcm[lg]t\tp[0-9]+\.s, p[0-7]/z, z[0-9]+\.s, z[0-9]+\.s\n} 12 } } */
69 /* { dg-final { scan-assembler-times {\tfcm[lg]t\tp[0-9]+\.d, p[0-7]/z, z[0-9]+\.d, z[0-9]+\.d\n} 24 } } */
70 
71 /* 2 each for: ole, ule, nule, oge, uge, nuge.  */
72 /* { dg-final { scan-assembler-times {\tfcm[lg]e\tp[0-9]+\.s, p[0-7]/z, z[0-9]+\.s, z[0-9]+\.s\n} 12 } } */
73 /* { dg-final { scan-assembler-times {\tfcm[lg]e\tp[0-9]+\.d, p[0-7]/z, z[0-9]+\.d, z[0-9]+\.d\n} 24 } } */
74 
75 /* 2 invocations for all 12 unordered comparisons.  */
76 /* { dg-final { scan-assembler-times {\tfcmuo\tp[0-9]+\.s, p[0-7]/z, z[0-9]+\.s, z[0-9]+\.s\n} 24 } } */
77 /* { dg-final { scan-assembler-times {\tfcmuo\tp[0-9]+\.d, p[0-7]/z, z[0-9]+\.d, z[0-9]+\.d\n} 48 } } */
78