1 /* { dg-require-effective-target vect_usad_char } */ 2 3 #include "tree-vect.h" 4 5 typedef unsigned int uint32_t; 6 typedef unsigned short uint16_t; 7 typedef unsigned char uint8_t; 8 9 extern int abs (int); 10 extern void abort (void); 11 12 int __attribute__((noinline,noclone)) foo(uint8_t * pix1,uint8_t * pix2,int i_stride_pix2)13foo (uint8_t *pix1, uint8_t *pix2, int i_stride_pix2) 14 { 15 int i_sum = 5; 16 for( int y = 0; y < 16; y++ ) 17 { 18 i_sum += abs ( pix1[0] - pix2[0] ); 19 i_sum += abs ( pix1[1] - pix2[1] ); 20 i_sum += abs ( pix1[2] - pix2[2] ); 21 i_sum += abs ( pix1[3] - pix2[3] ); 22 i_sum += abs ( pix1[4] - pix2[4] ); 23 i_sum += abs ( pix1[5] - pix2[5] ); 24 i_sum += abs ( pix1[6] - pix2[6] ); 25 i_sum += abs ( pix1[7] - pix2[7] ); 26 i_sum += abs ( pix1[8] - pix2[8] ); 27 i_sum += abs ( pix1[9] - pix2[9] ); 28 i_sum += abs ( pix1[10] - pix2[10] ); 29 i_sum += abs ( pix1[11] - pix2[11] ); 30 i_sum += abs ( pix1[12] - pix2[12] ); 31 i_sum += abs ( pix1[13] - pix2[13] ); 32 i_sum += abs ( pix1[14] - pix2[14] ); 33 i_sum += abs ( pix1[15] - pix2[15] ); 34 pix1 += 16; 35 pix2 += i_stride_pix2; 36 } 37 return i_sum; 38 } 39 40 int main()41main () 42 { 43 check_vect (); 44 45 uint8_t X[16*16]; 46 uint8_t Y[16*16]; 47 48 for (int i = 0; i < 16*16; ++i) 49 { 50 X[i] = i; 51 Y[i] = 16*16 - i; 52 __asm__ volatile (""); 53 } 54 55 if (foo (X, Y, 16) != 32512 + 5) 56 abort (); 57 58 return 0; 59 } 60 61 /* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ 62 /* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ 63 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ 64