PR middle-end/27945
[official-gcc.git] / gcc / testsuite / gcc.dg / pr9814-1.c
blob51b79f7839b5735220a545733020773191f3e821
1 /* PR tree-optimization/9814 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
5 extern void abort(void);
7 int test1(int x)
9 if (x & 2)
10 x |= 2;
11 return x;
14 int test2(int x)
16 if (!(x & 2))
17 x |= 2;
18 return x;
21 int test3(int x)
23 if (x & 2)
24 x ^= 2;
25 return x;
28 int test4(int x)
30 if (!(x & 2))
31 x ^= 2;
32 return x;
35 int test5(int x)
37 if (x & 2)
38 x &= ~2;
39 return x;
42 int test6(int x)
44 if (!(x & 2))
45 x &= ~2;
46 return x;
49 int main()
51 if (test1(0) != 0)
52 abort();
53 if (test1(2) != 2)
54 abort();
55 if (test1(5) != 5)
56 abort();
57 if (test1(7) != 7)
58 abort();
60 if (test2(0) != 2)
61 abort();
62 if (test2(2) != 2)
63 abort();
64 if (test2(5) != 7)
65 abort();
66 if (test2(7) != 7)
67 abort();
69 if (test3(0) != 0)
70 abort();
71 if (test3(2) != 0)
72 abort();
73 if (test3(5) != 5)
74 abort();
75 if (test3(7) != 5)
76 abort();
78 if (test4(0) != 2)
79 abort();
80 if (test4(2) != 2)
81 abort();
82 if (test4(5) != 7)
83 abort();
84 if (test4(7) != 7)
85 abort();
87 if (test5(0) != 0)
88 abort();
89 if (test5(2) != 0)
90 abort();
91 if (test5(5) != 5)
92 abort();
93 if (test5(7) != 5)
94 abort();
96 if (test6(0) != 0)
97 abort();
98 if (test6(2) != 2)
99 abort();
100 if (test6(5) != 5)
101 abort();
102 if (test6(7) != 7)
103 abort();
105 return 0;