1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize" } */ 3 4 #include <stdint.h> 5 6 #define abs(A) ((A) < 0 ? -(A) : (A)) 7 #define neg(A) (-(A)) 8 #define not(A) (~(A)) 9 10 #define DEF_LOOP(TYPE1, TYPE2, COUNT, OP) \ 11 void __attribute__ ((noipa)) \ 12 test_##TYPE1##_##TYPE2##_##OP (TYPE2 *__restrict r, \ 13 TYPE2 *__restrict a, \ 14 TYPE1 *__restrict pred) \ 15 { \ 16 for (int i = 0; i < COUNT; ++i) \ 17 r[i] = pred[i] ? OP (a[i]) : 5; \ 18 } 19 20 #define TEST_TYPES(T, TYPE1, TYPE2, COUNT) \ 21 T (TYPE1, TYPE2, COUNT, abs) \ 22 T (TYPE1, TYPE2, COUNT, neg) \ 23 T (TYPE1, TYPE2, COUNT, not) 24 25 #define TEST_ALL(T) \ 26 TEST_TYPES (T, int16_t, int8_t, 7) \ 27 TEST_TYPES (T, int32_t, int8_t, 3) \ 28 TEST_TYPES (T, int32_t, int16_t, 3) \ 29 TEST_TYPES (T, int64_t, int8_t, 5) \ 30 TEST_TYPES (T, int64_t, int16_t, 5) \ 31 TEST_TYPES (T, int64_t, int32_t, 5) 32 33 TEST_ALL (DEF_LOOP) 34 35 /* { dg-final { scan-assembler-times {\tabs\tz[0-9]+\.b, p[0-7]/m,} 3 } } */ 36 /* { dg-final { scan-assembler-times {\tabs\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ 37 /* { dg-final { scan-assembler-times {\tabs\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 38 39 /* { dg-final { scan-assembler-times {\tneg\tz[0-9]+\.b, p[0-7]/m,} 3 } } */ 40 /* { dg-final { scan-assembler-times {\tneg\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ 41 /* { dg-final { scan-assembler-times {\tneg\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 42 43 /* { dg-final { scan-assembler-times {\tnot\tz[0-9]+\.b, p[0-7]/m,} 3 } } */ 44 /* { dg-final { scan-assembler-times {\tnot\tz[0-9]+\.h, p[0-7]/m,} 2 } } */ 45 /* { dg-final { scan-assembler-times {\tnot\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 46 47 /* { dg-final { scan-assembler-not {\tmov\tz[^\n]*z} } } */ 48 /* { dg-final { scan-assembler-not {\tsel\t} } } */ 49