OSDN Git Service

* gcc.dg/vect/vect-116.c: Add vect_int target requirement.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-9.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 char uX[N] __attribute__ ((__aligned__(16)));
9 unsigned short uresult[N];
10 signed char X[N] __attribute__ ((__aligned__(16)));
11 short result[N];
12
13 /* Unsigned type promotion (qi->hi) */
14 int
15 foo1(int len) {
16   int i;
17
18   for (i=0; i<len; i++) {
19     uresult[i] = (unsigned short)uX[i];
20   }
21 }
22
23 /* Signed type promotion (qi->hi) */
24 int
25 foo2(int len) {
26   int i;
27
28   for (i=0; i<len; i++) {
29     result[i] = (short)X[i];
30   }
31 }
32
33 int main (void)
34 {
35   int i;
36
37   check_vect ();
38
39   for (i=0; i<N; i++) {
40     X[i] = 16-i;
41     uX[i] = 16-i;
42   }
43
44   foo1 (N);
45
46   for (i=0; i<N; i++) {
47     if (uresult[i] != (unsigned short)uX[i])
48       abort ();
49   }
50   
51   foo2 (N);
52   
53   for (i=0; i<N; i++) {
54     if (result[i] != (short)X[i])
55       abort ();
56   }
57   
58   return 0;
59 }
60
61 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */
62 /* { dg-final { cleanup-tree-dump "vect" } } */
63