gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O2" } */ |
| 3 | |
| 4 | void link_error (void); |
| 5 | |
| 6 | struct A |
| 7 | { |
| 8 | int a; |
| 9 | int b; |
| 10 | }; |
| 11 | |
| 12 | struct A a; |
| 13 | const int B = 42; |
| 14 | |
| 15 | void foo (int i) |
| 16 | { |
| 17 | if (i > 10) |
| 18 | a.a = 42; |
| 19 | else |
| 20 | { |
| 21 | a.b = 21; |
| 22 | a.a = a.b + 21; |
| 23 | } |
| 24 | |
| 25 | /* This should be folded to 'if (0)' as a.a and B are both 42. */ |
| 26 | if (a.a != B) |
| 27 | link_error (); |
| 28 | } |
| 29 | |
| 30 | int |
| 31 | main () |
| 32 | { |
| 33 | foo (3); |
| 34 | return 0; |
| 35 | } |