I am working on code optimization and going through gcc internals. I wrote a simple expression in my program and I checked the gimple representation of that expression and I got stuck why gcc had done this. Say I have an expression :
if(i < 9)
then in the gimple representation it will be converted to
if(i <= 8)
I dont know why gcc do this. Is it some kind of optimization, if yes then can anyone tell me how it can optimize our program?
The canonalisation helps to detect CommonSubExpressions, such as:
GCC -O1 will compile this into:
GCC -O2 will actually remove the entire loop and replace it by a stream of assignments.