This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization for automatic objects
- From: Joe Buck <jbuck at synopsys dot com>
- To: Joachim Schoeberl <js at jku dot at>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 23 Oct 2003 09:18:13 -0700
- Subject: Re: Optimization for automatic objects
- References: <3F97BF93.2030106@jku.at>
On Thu, Oct 23, 2003 at 01:46:27PM +0200, Joachim Schoeberl wrote:
> I have attached a complete small programme for computing
> vector = scalar * (scalar * vector), and the generated assembly code of
> func1.
>
> The actual computation loop is optimized very well (after .L32:).
> But, before that, there are many movements, which seem unnecessary to me,
> and should be eliminated by some optimization pass.
There is a basic defect in GCC in the treatment of struct and class objects;
they are committed to the stack too early, and the result is that after
their removal there are often dead stores left over. This problem does
not occur if the struct or class has only one data member.
I think that we're stuck with that problem until the tree-ssa work goes
live for 3.5.
> Now, my questions are:
> - is there an optimization flag eliminating these movements ?
Not right now.
> - should I implement the objects differently ?
If it is possible to arrange that the temporary objects have one data
member (e.g. a pointer), the compiler will probably do a much better
job of eliminating them.
> - will there be an optimizer in the near future ?
I'm afraid it's still a year off. I suppose it might be possible to
get some improvement with some kind of peephole optimization pass to
try to kill dead stores to the stack.