1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize" } */ 3 4 #define N 119 5 6 #define DEF_LOOP(INV, TYPE, CMPTYPE, SUFFIX) \ 7 void __attribute__ ((noipa)) \ 8 f_##INV##_##SUFFIX (TYPE *restrict a, TYPE *restrict b, \ 9 TYPE *restrict c, TYPE *restrict d, \ 10 CMPTYPE *restrict cond) \ 11 { \ 12 for (int i = 0; i < N; ++i) \ 13 { \ 14 TYPE mb = (INV & 1 ? -b[i] : b[i]); \ 15 TYPE mc = c[i]; \ 16 TYPE md = (INV & 2 ? -d[i] : d[i]); \ 17 TYPE fma = __builtin_fma##SUFFIX (mb, mc, md); \ 18 TYPE truev = (INV & 4 ? -fma : fma); \ 19 a[i] = cond[i] < 10 ? truev : d[i]; \ 20 } \ 21 } 22 23 #define FOR_EACH_TYPE(T, INV) \ 24 T (INV, _Float16, short, f16) \ 25 T (INV, float, float, f32) \ 26 T (INV, double, double, f64) 27 28 #define FOR_EACH_INV(T) \ 29 FOR_EACH_TYPE (T, 0) \ 30 FOR_EACH_TYPE (T, 1) \ 31 FOR_EACH_TYPE (T, 2) \ 32 FOR_EACH_TYPE (T, 3) \ 33 FOR_EACH_TYPE (T, 4) \ 34 FOR_EACH_TYPE (T, 5) \ 35 FOR_EACH_TYPE (T, 6) \ 36 FOR_EACH_TYPE (T, 7) 37 38 FOR_EACH_INV (DEF_LOOP) 39 40 /* { dg-final { scan-assembler-not {\tsel\t} } } */ 41 /* { dg-final { scan-assembler-not {\tmovprfx\t} } } */ 42 /* { dg-final { scan-assembler-not {\tmov\tz[0-9]+\.., z[0-9]+} } } */ 43 44 /* { dg-final { scan-assembler-times {\tfmla\tz[0-9]+\.h,} 2 } } */ 45 /* { dg-final { scan-assembler-times {\tfmla\tz[0-9]+\.s,} 2 } } */ 46 /* { dg-final { scan-assembler-times {\tfmla\tz[0-9]+\.d,} 2 } } */ 47 48 /* { dg-final { scan-assembler-times {\tfmls\tz[0-9]+\.h,} 2 } } */ 49 /* { dg-final { scan-assembler-times {\tfmls\tz[0-9]+\.s,} 2 } } */ 50 /* { dg-final { scan-assembler-times {\tfmls\tz[0-9]+\.d,} 2 } } */ 51 52 /* { dg-final { scan-assembler-times {\tfnmla\tz[0-9]+\.h,} 2 } } */ 53 /* { dg-final { scan-assembler-times {\tfnmla\tz[0-9]+\.s,} 2 } } */ 54 /* { dg-final { scan-assembler-times {\tfnmla\tz[0-9]+\.d,} 2 } } */ 55 56 /* { dg-final { scan-assembler-times {\tfnmls\tz[0-9]+\.h,} 2 } } */ 57 /* { dg-final { scan-assembler-times {\tfnmls\tz[0-9]+\.s,} 2 } } */ 58 /* { dg-final { scan-assembler-times {\tfnmls\tz[0-9]+\.d,} 2 } } */ 59