This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCSE PRE in GCC


I?am trying to use the GCSE/PRE pass to implement an optimization of
redundant loads due to stores.


I gave it several tries and found out that we have a problem due to the way
global variables are accessed - in such an access there will be one add and
two loads. Thus in order to eliminate the load GCSE must eliminate the add
in the first try , then the first load and finally the last load - a total
of 3 GCSE passes.


Bottom line , we need at least three iterations of "one_pre_gcse_pass".


I made some tries to see if the GCSE is capable of doing so in general and
wrote the below example.


It has a simple addition and multiplication expressions that are dependent;
GCC couldn't make the second pass elimination as it should (according to my
understanding) , it didn't remove the multiplication.


I have also looked at the RTL dump after gcse to confirm this.


Is this is a known problem? Am I doing some things wrong or misunderstood
what PRE should do?


I have compiled with gcc -O3 -S -dG --param max-gcse-passes=3


The code:


void g (int a , int b , int c);


void f (int x , int y , int z)


{


int a = 0, b = 0 , c= 0,t1,t2,t3;


if (z > 0 )


{


t1 = x + y;


a = t1 * z;


}


else


{


t2 = x + y;


b = t2 *z;


}


t3 = x + y; /* Redundant , should be removed by GCSE first try*/


c = t3 * z; /* Redundant , should be removed by GCSE second try*/


g(a,b,c);


}

Regards,
  Mostafa Hagog
 Systems and Software  Department
 IBM Research Lab in Haifa
 e-mail: mustafa at il dot ibm dot com
 Phone: +972 4 829-6518   Fax: +972 4 829-6112




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]