Consider this code, compiled with gcc
and -Ofast
:
int f1(const char *p) {
if (!p[0])
return 0;
f2(); //not inlined
if (p[0]) { //not optimized out
//do something
return 0;
} else {
//do something else
//not optimized out
return 1;
}
}
how can I get behavior where the second test and lower branch are optimized out (since p[0]
is const
and has already been tested)?