Some optimization thoughts (and thanks!)

Jan Hubicka jh@suse.cz
Wed May 2 07:32:00 GMT 2001


> * When branches are expensive, it might be reasonable to translate if 
>  statements with multiple conditions into merged condition and a single 
>  branch rather than multiple branches.  E.g., "if ((A==N) && (B==M))" 
>  might be translated into "XOR Temp1 A N; XOR Temp2 B M; OR Temp1 Temp2 
>  Temp1; BNEZ Temp1 L3; #branch over conditional code" rather than "XOR 
>  Temp1 A N; BNEZ Temp1 L3; #branch over second condition test and 
>  conditional code\\ XOR Temp1 B M; BNEZ Temp1 L3;"  Removing a branch 
>  might increase modality of the branch and decrease branch history 
>  table aliasing, improving branch prediction.  Such prediction 
>  improvement might compensate for the overhead of performing both tests 
>  in all cases.  (This is what happened in a test case using a pair of 
>  comparisons of a random number and a constant, at least performance 
>  improved on an x86-based system.) 
I've implemented this last month so I will try to contribute that
once I find time to polish thinks and test the code.

Honza



More information about the Gcc mailing list