首页 > 代码库 > Capabilities and Limitations of Optimizing Compilers

Capabilities and Limitations of Optimizing Compilers

 

Computer Systems A Programmer‘s Perspective Second Edition

 

 1 #include <stdio.h>
 2 
 3 main(){
 4     int wr;
 5     wr = func1();
 6 //    wr=func2();
 7     printf("%d",wr);
 8 }
 9 
10 int counter = 0;
11 int w(){
12     return counter++;
13 }
14 
15 int func1(){
16     return w()+w()+w()+w();
17 }
18 
19 int func2(){
20     return 4*w();
21 }
 
Modern compilers employ sophisticated algorithms to determine what values are
computed in a program and how they are used. 

 

Capabilities and Limitations of Optimizing Compilers