1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize" } */ 3 4 #include <stdint.h> 5 6 #define N 2000 7 8 #define TEST_LOOP(NAME, TYPE) \ 9 void __attribute__ ((noinline, noclone)) \ 10 NAME (TYPE *restrict dest, TYPE *restrict src) \ 11 { \ 12 for (int i = 0; i < N; ++i) \ 13 dest[i] += src[i * 2]; \ 14 } 15 16 #define TEST(NAME) \ 17 TEST_LOOP (NAME##_i8, int8_t) \ 18 TEST_LOOP (NAME##_i16, uint16_t) \ 19 TEST_LOOP (NAME##_f32, float) \ 20 TEST_LOOP (NAME##_f64, double) 21 22 TEST (test) 23 24 /* Check the vectorized loop. */ 25 /* { dg-final { scan-assembler-times {\tld1b\t} 1 } } */ 26 /* { dg-final { scan-assembler-times {\tld2b\t} 1 } } */ 27 /* { dg-final { scan-assembler-times {\tst1b\t} 1 } } */ 28 /* { dg-final { scan-assembler-times {\tld1h\t} 1 } } */ 29 /* { dg-final { scan-assembler-times {\tld2h\t} 1 } } */ 30 /* { dg-final { scan-assembler-times {\tst1h\t} 1 } } */ 31 /* { dg-final { scan-assembler-times {\tld1w\t} 1 } } */ 32 /* { dg-final { scan-assembler-times {\tld2w\t} 1 } } */ 33 /* { dg-final { scan-assembler-times {\tst1w\t} 1 } } */ 34 /* { dg-final { scan-assembler-times {\tld1d\t} 1 } } */ 35 /* { dg-final { scan-assembler-times {\tld2d\t} 1 } } */ 36 /* { dg-final { scan-assembler-times {\tst1d\t} 1 } } */ 37 38 /* Check the scalar tail. */ 39 /* { dg-final { scan-assembler-times {\tldrb\tw} 2 } } */ 40 /* { dg-final { scan-assembler-times {\tstrb\tw} 1 } } */ 41 /* { dg-final { scan-assembler-times {\tldrh\tw} 2 } } */ 42 /* { dg-final { scan-assembler-times {\tstrh\tw} 1 } } */ 43 /* { dg-final { scan-assembler-times {\tldr\ts} 2 } } */ 44 /* { dg-final { scan-assembler-times {\tstr\ts} 1 } } */ 45 /* { dg-final { scan-assembler-times {\tldr\td} 2 } } */ 46 /* { dg-final { scan-assembler-times {\tstr\td} 1 } } */ 47 48 /* The only branches should be in the vectorized loop. */ 49 /* { dg-final { scan-assembler-times {\tb[a-z]+\t} 4 } } */ 50