This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimizing GCC


Hello,

On Tue, 4 Mar 2003, Pop Sébastian wrote:
> On Tue, Mar 04, 2003 at 03:22:07PM +0100, Dag Bakke wrote:
> > 1. Can you expect a custom-optimized gcc binary and a default-optimized
> > gcc binary to produce the same output, if fed the same source and the
> > same options?
> >
> Yes.
>

At least for the version of gcc shiped with the SPEC CPU benchmarks, the
answer is no. Its code generation depends on the floating point precision
it uses. -march on x86 changes this a little and optimizing gcc that
way you get different assembly files. I guess it is because of the
optimizations and the generated programms should do the same. (I'm no gcc
programmer, but I trust their work.)

I don't know something about the actual gcc, but I think it still uses
floating point algorithms, so it's quite the same.

Using gcc 3.2.2 to compile the SPEC-gcc I had to use -ffloat-store along
with -march=pentium4 on x86 to get equal programs (compared to the non
optimized gcc). If "same" means to you, that the generated programs
only have "to do the same", -march is ok to use. (If it has no other
bugs, which I don't know. I only use gcc.)


I don't know if you can optimize the recent version of gcc with
-march. But I think it still uses floating point algorithms, so it'll be
quite the same.

Sorry for my bad english,

Herbert


> > I guess the answer is: "depends on how gcc was optimized", so the
> In part this is false: it depends only on whether the optimization flag
> you add to build gcc is safe or not.
>
> If the optimization doesn't introduce junks, in other words if the
> optimization is valid, then the optimized GCC is semantically equivalent
> to the non-optimized GCC.  Thus you'll get the same output for the same
> input on both versions of GCC.
>
> Otherwise it is an error in the optimization you used to optimize GCC.
>
> 	Sebastian
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]