1 /* { dg-require-effective-target vect_int } */ 2 3 #include "tree-vect.h" 4 5 #define N 50 6 7 #ifndef SIGNEDNESS 8 #define SIGNEDNESS unsigned 9 #endif 10 #ifndef BIAS 11 #define BIAS 0 12 #endif 13 14 void __attribute__ ((noipa)) f(SIGNEDNESS char * restrict a,SIGNEDNESS char * restrict b,SIGNEDNESS char * restrict c)15f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, 16 SIGNEDNESS char *restrict c) 17 { 18 for (__INTPTR_TYPE__ i = 0; i < N; ++i) 19 a[i] = (b[i] + c[i] + BIAS) >> 1; 20 } 21 22 #define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) 23 #define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) 24 25 int main(void)26main (void) 27 { 28 check_vect (); 29 30 SIGNEDNESS char a[N], b[N], c[N]; 31 for (int i = 0; i < N; ++i) 32 { 33 b[i] = BASE1 + i * 5; 34 c[i] = BASE2 + i * 4; 35 asm volatile ("" ::: "memory"); 36 } 37 f (a, b, c); 38 for (int i = 0; i < N; ++i) 39 if (a[i] != ((BASE1 + BASE2 + i * 9 + BIAS) >> 1)) 40 __builtin_abort (); 41 return 0; 42 } 43 44 /* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ 45 /* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ 46 /* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ 47 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ 48