Wednesday 15 January 2014

c++ - Is the compiler able to optimize spaghetti code? -



c++ - Is the compiler able to optimize spaghetti code? -

i writing compiler generates c++ code @ end, can't utilize while\for or other normal loop translate goto\if , assigments\call lines this:

if (i<b) goto loop_959__again; loop_959__end: ; } { int inumber; int i; i=0; inumber=3; if (!(inumber<30)) goto loop_4482__end; loop_4482__again: float fnumber; _a1__main__increase(__owner); i++; inumber++; fnumber=3; loop_4482__step_begin: if (inumber<30) goto loop_4482__again; loop_4482__end: ; }

this painful watch, can gcc compiler compile , optimize code 1 above if consisted of normal loops , etc?

compilers optimize programme command flow flow graphs analysis, using goto instead of if branch @ level practically equivalent compiler's standpoint.

a caveat maintain in mind: since gotos can jump around practically everywhere in function, if generator generates irreducible command flow graphs, might impact compiler's optimization capabilities.

c++ c gcc

No comments:

Post a Comment