I think the word "interprocedural" is the key here.
I am not familiar with gcc optimizer, but I used to work on optimizing compilers. The following are somewhat speculative; take it with a little salt or confirm it with someone who knows the gcc internals.
An optimizing compiler typically performs analysis and optimization only within each individual function (or subprogram or procedure, depending on the language). For example, this code, like this contrived example:
double *ptr = ...; void foo(void) { ... *ptr = 123.456; some_other_function(); printf("*ptr = %f\n", *ptr); }
the optimizer will not be able to determine if *ptr changed by calling some_other_function() .
If some_other_function() analysis is enabled, then the optimizer can analyze the behavior of some_other_function() , and it can prove that it cannot change *ptr . Given this analysis, it can determine that the expression *ptr should still be evaluated to 123.456 , and in principle it can even replace the printf call with puts("ptr = 123.456"); .
(Actually, with a small program similar to the code snippet above, I got the same generated code with -O3 and -O3 -fipa-pta , so I'm probably missing something.)
Since a typical program contains a large number of functions with a huge number of possible sequences of calls, such an analysis can be very expensive.
source share