libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / loop-unswitch-11.c
blobe9441316d0d35085e6d022a4118242aec4f292e1
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */
3 /* { dg-require-effective-target int32 } */
5 int
6 foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
8 for (int i = 0; i < size; i++)
10 double tmp, tmp2;
12 switch(order)
14 case 5 ... 6:
15 case 9:
16 tmp = -8 * a[i];
17 tmp2 = 2 * b[i];
18 break;
19 case 11:
20 tmp = 3 * a[i] - 2 * b[i];
21 tmp2 = 5 * b[i] - 2 * c[i];
22 break;
23 case 22:
24 tmp = 9 * a[i] + 2 * b[i] + c[i];
25 tmp2 = 4 * b[i] + 2 * c[i] + 8 * d[i];
26 break;
27 case 33:
28 tmp = 3 * a[i] + 2 * b[i] - c[i];
29 tmp2 = b[i] - 2 * c[i] + 8 * d[i];
30 break;
31 default:
32 __builtin_unreachable ();
35 double x = 3 * tmp + d[i] + tmp;
36 double y = 3.4f * tmp + d[i] + tmp2;
37 r[i] = x + y;
40 return 0;
43 /* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* \\+ 4294967291.*order.* == 9" 1 "unswitch" } } */
44 /* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 1" 1 "unswitch" } } */
45 /* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 2" 1 "unswitch" } } */
46 /* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 3" 1 "unswitch" } } */