1 /* { dg-require-effective-target vect_int } */ 2 /* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ 3 /* { dg-additional-options "-march=armv8.2-a+dotprod" { target { aarch64*-*-* } } } */ 4 /* { dg-add-options arm_v8_2a_dotprod_neon } */ 5 6 #include <stdarg.h> 7 #include "tree-vect.h" 8 9 #define N 64 10 11 #define DOT1 43680 12 13 signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); 14 signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); 15 16 /* char->short->int dot product. 17 The dot-product pattern should be detected. 18 Vectorizable on vect_sdot_qi targets (targets that support dot-product of 19 signed chars). 20 21 In the future could also be vectorized as widening-mult + widening-summation, 22 or with type-conversion support. 23 */ 24 __attribute__ ((noinline)) int foo1(int len)25foo1(int len) { 26 int i; 27 int result = 0; 28 short prod; 29 30 for (i=0; i<len; i++) { 31 prod = X[i] * Y[i]; 32 result += prod; 33 } 34 return result; 35 } 36 main(void)37int main (void) 38 { 39 int i, dot1; 40 41 check_vect (); 42 43 for (i=0; i<N; i++) { 44 X[i] = i; 45 Y[i] = 64-i; 46 __asm__ volatile (""); 47 } 48 49 dot1 = foo1 (N); 50 if (dot1 != DOT1) 51 abort (); 52 53 return 0; 54 } 55 56 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */ 57 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */ 58 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */ 59 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_mult_qi_to_hi && vect_widen_sum_hi_to_si } } } } */ 60 61