1 /* Disabling epilogues until we find a better way to deal with scans. */ 2 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ 3 /* { dg-require-effective-target vect_usad_char } */ 4 5 #include <stdarg.h> 6 #include "tree-vect.h" 7 8 #define N 64 9 #define SAD N*N/2 10 11 unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); 12 unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); 13 int abs (int); 14 15 /* Sum of absolute differences between arrays of unsigned char types. 16 Detected as a sad pattern. 17 Vectorized on targets that support sad for unsigned chars. */ 18 19 __attribute__ ((noinline)) int foo(int len)20foo (int len) 21 { 22 int i; 23 int result = 0; 24 25 for (i = 0; i < len; i++) 26 result += abs (X[i] - Y[i]); 27 28 return result; 29 } 30 31 32 int main(void)33main (void) 34 { 35 int i; 36 int sad; 37 38 check_vect (); 39 40 for (i = 0; i < N; i++) 41 { 42 X[i] = i; 43 Y[i] = N - i; 44 __asm__ volatile (""); 45 } 46 47 sad = foo (N); 48 if (sad != SAD) 49 abort (); 50 51 return 0; 52 } 53 54 /* { dg-final { scan-tree-dump-times "sad pattern recognized" 1 "vect" } } */ 55 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ 56 57