This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: how to fix anti-optimization?
- To: dalej at apple dot com
- Subject: Re: how to fix anti-optimization?
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Fri, 14 Sep 01 18:33:04 EDT
- Cc: gcc at gcc dot gnu dot org
const double Prescale[] = { 3.0, 5.0 };
extern void bar(double, double);
void foo () { bar(Prescale[0], Prescale[1]); }
With -O1 or higher, gcc substitutes constants 3.0 and 5.0 for the array
references. This isn't a win on targets where the extra copies of these
constants have to go in memory; you get an extra copy of the constants in
data space.
Only if it's no more complex an expression. Consider Prescale[0]*Prescale[1].
It's *much* faster to do the folding in that case.