OSDN Git Service

Latest updates from FSF 4.7 branch
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pr46309.c
1 /* PR tree-optimization/46309 */
2 /* { dg-do compile } */
3 /* { dg-skip-if "branch cost is always one" { "frv-*-*" "m32c-*-*" "mn10300-*-*" "sh-*-*" } "*" { "" } } */
4 /* { dg-options "-O2 -fdump-tree-reassoc-details" } */
5 /* The transformation depends on BRANCH_COST being greater than 1
6    (see the notes in the PR), so try to force that.  */
7 /* { dg-additional-options "-mtune=octeon2" { target mips*-*-* } } */
8 /* { dg-additional-options "-mbranch-cost=2" { target avr*-*-* s390*-*-* } } */
9
10 int
11 f1 (int a)
12 {
13   int v1 = (a == 3);
14   int v2 = (a == 1);
15   int v3 = (a == 4);
16   int v4 = (a == 2);
17   return v1 || v2 || v3 || v4;
18 }
19
20 int
21 f2 (int a)
22 {
23   int v1 = (a == 1);
24   int v2 = (a == 2);
25   int v3 = (a == 3);
26   int v4 = (a == 4);
27   return v1 || v2 || v3 || v4;
28 }
29
30 int
31 f3 (int a)
32 {
33   int v1 = (a == 3);
34   int v2 = (a == 1);
35   return v1 || v2;
36 }
37
38 int
39 f4 (int a)
40 {
41   int v1 = (a == 1);
42   int v2 = (a == 2);
43   return v1 || v2;
44 }
45
46 int
47 f5 (unsigned int a)
48 {
49   int v1 = (a <= 31);
50   int v2 = (a >= 64 && a <= 95);
51   return v1 || v2;
52 }
53
54 int
55 f6 (unsigned int a)
56 {
57   int v1 = (a <= 31);
58   int v2 = (a >= 64 && a <= 95);
59   int v3 = (a >= 128 && a <= 159);
60   int v4 = (a >= 192 && a <= 223);
61   return v1 || v2 || v3 || v4;
62 }
63
64 /* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 2 "reassoc1" } } */
65 /* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.3, 3.\[\n\r\]* into" 1 "reassoc1" } } */
66 /* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2.\[\n\r\]* into" 1 "reassoc1" } } */
67 /* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.0, 31. and -.64, 95.\[\n\r\]* into" 2 "reassoc1" } } */
68 /* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.128, 159. and -.192, 223.\[\n\r\]* into" 1 "reassoc1" } } */
69 /* { dg-final { scan-tree-dump-times "Optimizing range tests D.\[0-9\]*_\[0-9\]* -.0, 31. and -.128, 159.\[\n\r\]* into" 1 "reassoc2" } } */
70 /* { dg-final { cleanup-tree-dump "reassoc1" } } */
71 /* { dg-final { cleanup-tree-dump "reassoc2" } } */