1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize" } */ 3 4 #include <stdint.h> 5 6 #define DEF_LOOP(TYPE, NAME, OP) \ 7 void __attribute__ ((noipa)) \ 8 test_##TYPE##_##NAME (TYPE *__restrict r, \ 9 TYPE *__restrict a, \ 10 TYPE *__restrict b, TYPE c, \ 11 TYPE *__restrict pred, int n) \ 12 { \ 13 for (int i = 0; i < n; ++i) \ 14 r[i] = pred[i] != 1 ? a[i] OP b[i] * c : b[i]; \ 15 } 16 17 #define TEST_TYPE(T, TYPE) \ 18 T (TYPE, add, +) \ 19 T (TYPE, sub, -) 20 21 #define TEST_ALL(T) \ 22 TEST_TYPE (T, uint8_t) \ 23 TEST_TYPE (T, uint16_t) \ 24 TEST_TYPE (T, uint32_t) \ 25 TEST_TYPE (T, uint64_t) \ 26 TEST_TYPE (T, _Float16) \ 27 TEST_TYPE (T, float) \ 28 TEST_TYPE (T, double) 29 30 TEST_ALL (DEF_LOOP) 31 32 /* { dg-final { scan-assembler-times {\tmad\tz[0-9]+\.b, p[0-7]/m,} 1 } } */ 33 /* { dg-final { scan-assembler-times {\tmad\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ 34 /* { dg-final { scan-assembler-times {\tmad\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 35 /* { dg-final { scan-assembler-times {\tmad\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ 36 37 /* { dg-final { scan-assembler-times {\tmsb\tz[0-9]+\.b, p[0-7]/m,} 1 } } */ 38 /* { dg-final { scan-assembler-times {\tmsb\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ 39 /* { dg-final { scan-assembler-times {\tmsb\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 40 /* { dg-final { scan-assembler-times {\tmsb\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ 41 42 /* { dg-final { scan-assembler-times {\tfmad\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ 43 /* { dg-final { scan-assembler-times {\tfmad\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 44 /* { dg-final { scan-assembler-times {\tfmad\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ 45 46 /* { dg-final { scan-assembler-times {\tfmsb\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ 47 /* { dg-final { scan-assembler-times {\tfmsb\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 48 /* { dg-final { scan-assembler-times {\tfmsb\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ 49 50 /* { dg-final { scan-assembler-not {\tmov\tz[^,]*z} } } */ 51 /* { dg-final { scan-assembler-not {\tmovprfx\t} } } */ 52 /* { dg-final { scan-assembler-not {\tsel\t} } } */ 53