OSDN Git Service

PR tree-optimization/40238
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-widen-mult-u16.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 64
7
8 unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
9 unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
10 unsigned int result[N];
11
12 /* short->int widening-mult */
13 __attribute__ ((noinline)) int
14 foo1(int len) {
15   int i;
16
17   /* Not vectorized because X[i] and Y[i] are casted to 'int'
18      so the widening multiplication pattern is not recognized.  */
19   for (i=0; i<len; i++) {
20     result[i] = (unsigned int)(X[i] * Y[i]);
21   }
22 }
23
24 int main (void)
25 {
26   int i;
27
28   check_vect ();
29
30   for (i=0; i<N; i++) {
31     X[i] = i;
32     Y[i] = 64-i;
33   }
34
35   foo1 (N);
36
37   for (i=0; i<N; i++) {
38     if (result[i] != X[i] * Y[i])
39       abort ();
40   }
41   
42   return 0;
43 }
44
45 /*The induction loop is vectorized  */
46 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
47 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */
48 /* { dg-final { cleanup-tree-dump "vect" } } */
49