1 /* { dg-do compile } */
2 /* { dg-options "-O2 -funswitch-loops -fno-thread-jumps -fdump-tree-unswitch-optimized" } */
3
4 int
5 foo(double *a, double *b, double *c, double *d, double *r, int size, unsigned order)
6 {
7 for (int i = 0; i < size; i++)
8 {
9 double tmp;
10
11 switch (order)
12 {
13 case 0 ... 4:
14 tmp = -8 * a[i];
15 break;
16 default:
17 tmp = -4 * b[i];
18 break;
19 }
20
21 double x = 3 * tmp + d[i] + tmp;
22
23 /* This and the case 0 ... 4 condition should only be unswitched once
24 since they are mutually excluded. */
25 if (order >= 5)
26 x += 2;
27
28 double y = 3.4f * tmp + d[i];
29 r[i] = x + y;
30 }
31
32 return 0;
33 }
34
35 /* { dg-final { scan-tree-dump-times "unswitching loop . on .\[^\n\r\]*. with condition" 1 "unswitch" } } */