Messages in this thread | | | From | "Peter T. Breuer" <> | Subject | Re: useful exercise | Date | Mon, 11 Jan 1999 02:12:05 +0100 (MET) |
| |
"A month of sundays ago Jamie Lokier wrote:" > > Pros > 1. Some errors spotted earlier in the development process.
The aim.
> Cons > > 1. Some things will optimise worse if you use `if' -- e.g., if > an `if (0)' branch takes the address of a variable, that will > still suppress some optimisations of that variable even when > the branch is optimised away. However, I'm don't think > that's all that common, and GCC can always be tweaked in the > long run if it is worth doing.
Interesting.
> I personally prefer #if X and if (X), because it is more flexible. It's > unusual for a config option to make a lot of difference to the amount of > code compiled in a single file, so that's not so important.
Do you happen to know if
const int C_FOO = 1;
would lead to the other branch in an if(C_FOO) being optimized away?
One of the things I am fairly certain of wrt gcc is that optimization is functionwise, which means that I don't know if globals will be considered at all when doing expression reduction. If global constants aren't optimized as constants, then #define C_FOO 1 is forced upon us. Pity. The int has the advantage of possibly raising a warning in the future if used in an #ifdef (by mistake).
> -- Jamie
Peter
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |