gcc/testsuite/g++.dg/ipa/pure-const-1.C
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-O2 -fdump-tree-optimized -fno-ipa-vrp" } */ |
| 3 | int *ptr; |
| 4 | static int barvar; |
| 5 | |
| 6 | /* We can not detect A to be const because it may be interposed by unoptimized |
| 7 | body. */ |
| 8 | inline |
| 9 | __attribute__ ((noinline)) |
| 10 | int a(void) |
| 11 | { |
| 12 | return *ptr == *ptr; |
| 13 | } |
| 14 | int main() |
| 15 | { |
| 16 | int aa; |
| 17 | ptr = &barvar; |
| 18 | aa=!a(); |
| 19 | ptr = 0; |
| 20 | return aa; |
| 21 | } |
| 22 | /* { dg-final { scan-tree-dump "barvar" "optimized" } } */ |