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 { 20 int tmp1 = b[i] + BIAS; 21 int tmp2 = tmp1 + c[i]; 22 a[i] = tmp2 >> 1; 23 } 24 } 25 26 #define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) 27 #define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) 28 29 int main(void)30main (void) 31 { 32 check_vect (); 33 34 SIGNEDNESS char a[N], b[N], c[N]; 35 for (int i = 0; i < N; ++i) 36 { 37 b[i] = BASE1 + i * 5; 38 c[i] = BASE2 + i * 4; 39 asm volatile ("" ::: "memory"); 40 } 41 f (a, b, c); 42 for (int i = 0; i < N; ++i) 43 if (a[i] != ((BASE1 + BASE2 + i * 9 + BIAS) >> 1)) 44 __builtin_abort (); 45 return 0; 46 } 47 48 /* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ 49 /* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ 50 /* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ 51 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ 52