OSDN Git Service

PR tree-optimization/40542
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / bb-slp-20.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include <stdio.h>
5 #include "tree-vect.h"
6
7 #define N 16 
8
9 int b[N];
10 unsigned int out[N];
11 unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
12
13 __attribute__ ((noinline)) int
14 main1 (unsigned int x, unsigned int y)
15 {
16   int i;
17   unsigned int a0, a1, a2, a3;
18
19   if (x > y)
20     x = x + y;
21   else
22     y = x;
23
24   /* Two SLP instances in the basic block, only one is supported for now,
25      the second one contains type conversion.  */
26   a0 = in[0] + 23;
27   a1 = in[1] + 142;
28   a2 = in[2] + 2;
29   a3 = in[3] + 31;
30  
31   b[0] = -a0;
32   b[1] = -a1;
33   b[2] = -a2;
34   b[3] = -a3;
35   
36   out[0] = a0 * x;
37   out[1] = a1 * y;
38   out[2] = a2 * x;
39   out[3] = a3 * y;
40
41   /* Check results.  */
42   if (out[0] != (in[0] + 23) * x
43       || out[1] != (in[1] + 142) * y
44       || out[2] != (in[2] + 2) * x
45       || out[3] != (in[3] + 31) * y
46       || b[0] != -(in[0] + 23)
47       || b[1] != -(in[1] + 142)
48       || b[2] != -(in[2] + 2)
49       || b[3] != -(in[3] + 31))
50       
51     abort();
52
53   return 0;
54 }
55
56 int main (void)
57 {
58   check_vect ();
59
60   main1 (2, 3);
61
62   return 0;
63 }
64
65 /* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 1 "slp" { target vect_int_mult } } } */
66 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "slp" { target vect_int_mult } } } */
67 /* { dg-final { cleanup-tree-dump "slp" } } */
68