1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize" } */ 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 DEF_LOOP(CMP, EXPECT_INVALID) \ 26 void __attribute__ ((noinline, noclone)) \ 27 test_##CMP##_var (__fp16 *restrict dest, __fp16 *restrict src, \ 28 __fp16 fallback, __fp16 *restrict a, \ 29 __fp16 *restrict b, int count) \ 30 { \ 31 for (int i = 0; i < count; ++i) \ 32 dest[i] = CMP (a[i], b[i]) ? src[i] : fallback; \ 33 } \ 34 \ 35 void __attribute__ ((noinline, noclone)) \ 36 test_##CMP##_zero (__fp16 *restrict dest, __fp16 *restrict src, \ 37 __fp16 fallback, __fp16 *restrict a, \ 38 int count) \ 39 { \ 40 for (int i = 0; i < count; ++i) \ 41 dest[i] = CMP (a[i], (__fp16) 0) ? src[i] : fallback; \ 42 } \ 43 \ 44 void __attribute__ ((noinline, noclone)) \ 45 test_##CMP##_sel (__fp16 *restrict dest, __fp16 if_true, \ 46 __fp16 if_false, __fp16 *restrict a, \ 47 __fp16 b, int count) \ 48 { \ 49 for (int i = 0; i < count; ++i) \ 50 dest[i] = CMP (a[i], b) ? if_true : if_false; \ 51 } 52 53 #define TEST_ALL(T) \ 54 T (eq, 0) \ 55 T (ne, 0) \ 56 T (olt, 1) \ 57 T (ole, 1) \ 58 T (oge, 1) \ 59 T (ogt, 1) \ 60 T (ordered, 0) \ 61 T (unordered, 0) \ 62 T (ueq, 0) \ 63 T (ult, 0) \ 64 T (ule, 0) \ 65 T (uge, 0) \ 66 T (ugt, 0) \ 67 T (nueq, 0) \ 68 T (nult, 0) \ 69 T (nule, 0) \ 70 T (nuge, 0) \ 71 T (nugt, 0) 72 73 TEST_ALL (DEF_LOOP) 74 75 /* { dg-final { scan-assembler {\tfcmeq\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} { xfail *-*-* } } } */ 76 /* { dg-final { scan-assembler {\tfcmeq\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 77 78 /* { dg-final { scan-assembler {\tfcmne\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 79 /* { dg-final { scan-assembler {\tfcmne\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 80 81 /* { dg-final { scan-assembler {\tfcmlt\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 82 /* { dg-final { scan-assembler {\tfcmlt\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 83 84 /* { dg-final { scan-assembler {\tfcmle\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 85 /* { dg-final { scan-assembler {\tfcmle\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 86 87 /* { dg-final { scan-assembler {\tfcmgt\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 88 /* { dg-final { scan-assembler {\tfcmgt\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 89 90 /* { dg-final { scan-assembler {\tfcmge\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 91 /* { dg-final { scan-assembler {\tfcmge\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 92 93 /* { dg-final { scan-assembler-not {\tfcmuo\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, #0\.0\n} } } */ 94 /* { dg-final { scan-assembler {\tfcmuo\tp[0-9]+\.h, p[0-7]/z, z[0-9]+\.h, z[0-9]+\.h\n} } } */ 95